New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AndroidExecutionScope doesn't work #38
Comments
hiya - what version are you using? thanks! |
jdeferred-android-aar v1.2.3 |
@jamchamb could I trouble you to provide a full example? thanks! |
mm, i can't seem to reproduce this. any additional info would be great. thanks! |
To clarify, I'm trying to initiate the promise from a UI (main) thread and have my callback functions run in a background thread. For example, I would have something like this in an AndroidDeferredManager dm = new AndroidDeferredManager();
dm.when(somePromise, AndroidExecutionScope.BACKGROUND).done(new DoneCallback<Something>() {
@Override
public void onDone(Something result) {
// Stuff I want to be handled in a background thread
if (Looper.myLooper() == Looper.getMainLooper()) Log.e(TAG, "On main thread");
}
}); I can write up a full working example later. |
I see. Let me give that a try as well. I've used AndroidDoneCallback and that seemed to work just fine as well.. |
Oh, btw, how did you construct the somePromise? |
The same here, callback is always executed in MAIN THREAD. |
@saturnism, i'm testing this way:
I create a class that handle responses from my backend server called RequestPromise
Activity:
|
Looking the code on AndroidDeferredObject:
The "else" code should not ensure that the code will run on background? |
I found that in |
A |
How should I run that |
A promise isn't something you can run. Think of it as a For an example of this, please see https://github.com/jdeferred/jdeferred#runnable-and-callable and the "using your own Deferred object". Thanks! |
Closing for now. Thanks! |
I'm trying to get certain callbacks to run in the background by using AndroidDeferredManager and Android****Callback functions that return AndroidExecutionScope.BACKGROUND in getExecutionScope(), but no matter what the callbacks always seem to execute on the main UI thread.
This is the test I'm using to see which thread the callback is executing on:
Even using DefaultDeferredManager, the callbacks run in the main UI thread. The only thing that does work is the DeferredAsyncTask passed to the AndroidDeferredManager, but I would like to be able to use the callbacks.
If this is not a bug, please provide more documentation/examples on how to use these callbacks on Android.
The text was updated successfully, but these errors were encountered: