Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Long operations on Activity's onCreate()

I have an Activity that retrieves information from a remote server and displays it in a TableLayout. The function that retrieves the information from the server has its own timeout, and exception is thrown when the timeout gets exceeded.

Now, when the activity is loaded, I want the function to be fired, and a progressDialog to be shown while the function works, and to be hided if the function is done working, or if a timeout exception was thrown.

The problem: I've put the code that do all the functionality described above in the onCreate() function. Nothing is shown on the emulator screen, since the onCreate() function hasn't finished running...

I've also tried to put the code in the onStart() function... same unwanted results...

I'm trying to avoid using of threads, because the functionality needs many variables that the thread will not has access to them...

How can i implement the wanted behavior??

Thanks.

like image 592
ofirbt Avatar asked Dec 01 '25 08:12

ofirbt


1 Answers

Use AsyncTask with ProgressDialog bounded:

http://it-projects.spb.ru/?p=150&lang=en

like image 86
Vladimir Ivanov Avatar answered Dec 03 '25 21:12

Vladimir Ivanov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!