Showing Loading screen during REST service request in android app ?

Posted by sat on Stack Overflow See other posts from Stack Overflow or by sat
Published on 2011-02-18T06:55:57Z Indexed on 2011/02/18 7:25 UTC
Read the original article Hit count: 217

Currently here is what I am following, As soon as my app is launched, I have to send a request for REST service, It will take little time , so I thought of showing loading screen,

In onCreate() of my Activity , first thing will be to show loading screen(progress dialog) , And I kick off the background Activity using AsyncTask , i.e. requesting for REST service and onPostexecute() I close the dialog and then I do setContentView(myxml); and update the UI .

Can this approach be improved ?

Problem which I faced was ,

Sometimes , Garbage collector may start(due to various reasons) and my app hangs at loading screen forever , because of Garbage collector , even request for REST service is not sent and because of it some wake up call comes and rest is disaster and Force close.

But sometimes even ForceClose doesnot come fast , may be because of GC. so I cannot even go back and stuck in loading screen. Only thing which I can do at that point is to come back HOME. After that If I come back to my app its still loading , so definitely this approach seems to be a bad design. Whats the right approach ?

© Stack Overflow or respective owner

Related posts about android

Related posts about android-widget