emportella
emportella

Reputation: 333

How do I get response from Azure Mobile Service to confirm sending?

i'm currently building a simple android app that sends info to Azure mobile services. I'm using the below example code of the tutorial.

mSClient = new MobileServiceClient(URL, KEY, context);
mSClient = getMSClient();
mSClient.getTable(MyClass.class).insert(form, new TableOperationCallback<MyClass>() {
   public void onCompleted(MyClass entity, Exception exception, ServiceFilterResponse response) {
                   if (exception != null) {                       
                      Log.e("MSG", exception.getLocalizedMessage());                       
                  }                    
                 if (response != null) {                      
                    Log.e("MSG", response.getContent());                   
               }
          }                
     });

Now, how do I get the response from ServiceFilterResponse in onComplete method that takes a while to get and the MobileServiceClient have done its work already. How do I wait to flag my info on sqlite as sent?

Upvotes: 0

Views: 447

Answers (1)

carlosfigueira
carlosfigueira

Reputation: 87218

When the callback is invoked, it means that the insertion operation already finished at the server side. If you want to flag something between the moment you send the 'insert' request (which is basically a HTTP POST request) to the moment the operation is complete: right

mSClient = new MobileServiceClient(URL, KEY, context);
mSClient = getMSClient();
mSClient.getTable(MyClass.class).insert(form, new TableOperationCallback<MyClass>() {
   public void onCompleted(MyClass entity, Exception exception, ServiceFilterResponse response) {
      if (exception != null) {                       
         // here: tell sqlite that the insert request failed
         Log.e("MSG", exception.getLocalizedMessage());                       
      } else {
         // here: tell sqlite that the insert request succeeded
         Log.e("MSG", response.getContent());
      }
   }                
});
// here: tell sqlite that the insert request was sent

Upvotes: 1

Related Questions