Friday, September 2, 2016

Synchronous AsyncTask in Android

In Android , there are some APIs (specially network related ) can called from another thread. and there will be some situation you will be encountered that , the main thread needs result of the Asynctask thread .

well , it is quite easy in android

you have to use below piece of code

             new TimerTask().execute().get();


timertask is extends from AsyncTask .

ie Thread1 will wait for thread2's result .

No comments:

Post a Comment