Skip to content
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

Exception sending message to a Handler on a dead thread in SycnHttpClient #421

Closed
ramashishb opened this issue Jan 3, 2014 · 1 comment
Assignees
Labels
Milestone

Comments

@ramashishb
Copy link

Hi,

I am using SyncHttpClient to make synchronous requests from an IntentService. Here is the sample code-

SyncHttpClient syncClient  = new SyncHttpClient();
// other initialization like JsonHttpResponseHandler
syncClient.get(url, parameters, responseHandler);

After making the request, I expect the onSuccess or onFailure to be called. Instead, I get the following exception-

java.lang.RuntimeException: Handler (com.loopj.android.http.AsyncHttpResponseHandler$ResponderHandler) {53554578} sending message to a Handler on a dead thread
        at android.os.MessageQueue.enqueueMessage(MessageQueue.java:294)
        at android.os.Handler.sendMessageAtTime(Handler.java:473)
        at android.os.Handler.sendMessageDelayed(Handler.java:446)
        at android.os.Handler.post(Handler.java:263)
        at com.loopj.android.http.AsyncHttpResponseHandler.postRunnable(AsyncHttpResponseHandler.java:412)
        at com.loopj.android.http.JsonHttpResponseHandler$1.run(JsonHttpResponseHandler.java:153)
        at java.lang.Thread.run(Thread.java:856)

What's the correct way to make synchronous requests?

@ghost ghost assigned smarek Jan 11, 2014
@smarek
Copy link
Member

smarek commented Mar 29, 2014

This is already fixed, I've also added example of SyncHttpClient, see: https://github.com/loopj/android-async-http/blob/master/sample/src/main/java/com/loopj/android/http/sample/SynchronousClientSample.java

Not IntentService, but it is not different, for Service

@smarek smarek closed this as completed Mar 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants