Is android-asynct-http library coupled with UI thread? -


i want use awesome library server request in application work on map. my need want make server request every 2 minutes without block user interaction on screen while server requesting process happening , in onsuccess call i'll work on map. how can use library need? , the library coupled android activity , fragment life cycle?

please refer site library information. http://loopj.com/android-async-http/

actually that's page linked http://loopj.com/android-async-http/ . theses callbacks executed in ui thread actual request being processed in thread.

asynchttpclient client = new asynchttpclient(); client.get("http://www.google.com", new asynchttpresponsehandler() {      @override     public void onstart() {         // called before request started     }      @override     public void onsuccess(int statuscode, header[] headers, byte[] response) {         // called when response http status "200 ok"     }      @override     public void onfailure(int statuscode, header[] headers, byte[] errorresponse, throwable e) {         // called when response http status "4xx" (eg. 401, 403, 404)     }      @override     public void onretry(int retryno) {         // called when request retried     } }); 

in activity's onstop() should call asynchttpclient's cancelallrequests(context context, boolean mayinterruptifrunning) method cancel active , pending requests.

client.cancelallrequests(this, true); 

this should ensure callbacks of requests never called , save non trivial network usage , save illegalstateexceptions.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -