Is there any difference between the following 2 methods
Pending Result
VS
New Thread
From what I have read, both run the code 'not in the main UI thread'.
Pending Result
B4X:
PendingResult<MessageApi.SendMessageResult> results = Wearable.MessageApi.sendMessage(mGoogleApiClient, NodeID, msgPath, Data.getBytes());
results.setResultCallback(new ResultCallback<MessageApi.SendMessageResult>() {
@Override
public void onResult(SendMessageResult msgResult) {
if (mBA.subExists(mEventname + "_messagesent")) {
boolean Success = false;
if (msgResult.getStatus().isSuccess()) {
Success = true;
}
mBA.raiseEvent(mGoogleApiClient, mEventname + "_messagesent", new Object[] {Success});
}
}
});
New Thread
B4X:
new Thread(new Runnable() {
@Override
public void run() {
BA.Log("Sending message to " + NodeID);
mGoogleApiClient.blockingConnect(Timeout, TimeUnit.MILLISECONDS);
SendMessageResult result = Wearable.MessageApi.sendMessage(mGoogleApiClient, NodeID, msgPath, Data.getBytes()).await();
boolean success = false;
if (result.getStatus().isSuccess()) {
success = true;
}
if (mBA.subExists(mEventname + "_messagesent")) {
mBA.raiseEvent(mGoogleApiClient, mEventname + "_messagesent", new Object[] {success});
}
}
}).start();
}
From what I have read, both run the code 'not in the main UI thread'.