3

Async calls are great and it seems all the calls using the Quickblox Android SDK are async allowing for easy implementation from the main ui thread.

but I need the ability to abort a call to the server as my calls are made by sync adapters and can be canceled or aborted in the middle of the process.

Boon
  • 1,871
  • 1
  • 21
  • 31

2 Answers2

2

You can disable async calls in Android SDK - please look at Synchronous requests are available

And wrap this call on your own async task or something else.

Then you will be able to cancel queries

Rubycon
  • 18,156
  • 10
  • 49
  • 70
  • Thanks, I know about this option, but is it shouldn't be used for production products as per documentation, I would prefer to use the Async functionality with an abort signal. – user1934104 Jan 02 '13 at 16:18
  • No, if you a good skills developer - you can use this. Sync queries can produces ANR, so, be aware about this – Rubycon Jan 02 '13 at 16:54
  • Interesting, this still leaves me in the position that once the call is made I need to wait for the call to complete before I can abort it. My next question is what web client are you using to make the call (UrlConnection/ HttpDefaultClient)? – user1934104 Jan 02 '13 at 17:27
  • we are using DefaultHttpClient – Rubycon Jan 02 '13 at 19:25
  • We are going to add in next version opportunity to cancel queries. We are going to release new version of Android SDK during 2 next weeks – Rubycon Jan 08 '13 at 15:05
1

Android SDK 0.7 was released http://quickblox.com/blog/2013/01/android-sdk-0-7/

Now just use this code to cancel query:

QBRequestCanceler canceler =  QBUsers.getUser(37823232, new QBCallbackImpl() {
    @Override
    public void onComplete(Result result) {
         if (result.isSuccess()) {
               QBUserResult qbUserResult = (QBUserResult) result;
               System.out.println(">>> User: " + qbUserResult.getUser().toString());
         } else {
               handleErrors(result);
         }
    }
});

...    

// cancel if need
canceler.cancel();
Rubycon
  • 18,156
  • 10
  • 49
  • 70