I have created an app in android. Now I want to create a web version using PlayN. What I want is to replace all the android specific code to normal java code. In android version I use Async task. What can I use instead of this?
Asked
Active
Viewed 2,470 times
5
-
this can help : http://docs.oracle.com/javase/tutorial/uiswing/concurrency/simple.html – Nibha Jain Feb 24 '12 at 12:04
-
Wow, that's quite a mission. I hope you do well with that. Let us know how it goes. – ashes999 Feb 24 '12 at 12:05
-
Here is a AsynTask file which you might use it as a Java code https://github.com/android/platform_frameworks_base/blob/master/core/java/android/os/AsyncTask.java – Vinayak Bevinakatti Feb 24 '12 at 12:07
-
nibha, I am using PlayN. will swing be a good option then? – Rockcollins Feb 24 '12 at 12:16
-
Vinayak, You mean I have to pull the class from there and use it in my code? – Rockcollins Feb 24 '12 at 12:21
3 Answers
3
Async Task is nothing but just a separate thread.You can create your on thread and add the code which you written in doInBackground(Void... params) in the thread's run() method.

Dhaval
- 553
- 3
- 9
-
Dhavai what about onPreExecute and onPostExecute ? And I need to update UI too. – Rockcollins Feb 24 '12 at 12:15
-
This thing is done by your main thread which call childthread.start() method. – Dhaval Feb 24 '12 at 12:23
-
1and see the Thread.Join() function. By this function u can block your main thread till the childthread is complete its work. And after join() write your onPostExecute () code. – Dhaval Feb 24 '12 at 12:26
1
You can download the Android Source and copy the AsyncTask source to your project. Its does not have dependency of Android.
You can find AsyncTask.java here

Vivek Khandelwal
- 7,829
- 3
- 25
- 40