LoopJ AndroidAsyncHttp GET gets cancelled on screen rotate?

183 views Asked by At

I execute the following code that does not execute if I rotate the screen:

AsyncHttpClient client = new AsyncHttpClient();
client.get(absoluteUrl, params, responseHandler);

It surprised me that the network request was cancelled because if I used a custom asynctask to make a network call using, say, URLConnection it would still run even after the activity was destroyed. Am I to understand that loopj's AndroidAsyncHttp cancels the network request when the activity is destroyed? How can I prevent this?

1

There are 1 answers

0
Neo On

I need more information to help you. What I can tell you is that by default android destroys and recreates an activity on rotation.

If you specify the following in your android manifest:

      <activity
        android:name=".exampleActivity"
        android:configChanges="orientation"
    </activity>

The activity wont be destroyed but onConfigurationChanged will be called instead.

Hoped this helped 8=)