I am working on an android app and I have an async task in one activity and I want to use that async task into another activity. Can I do so?
Asked
Active
Viewed 547 times
0
-
2You can move async task to new class and listen to it using [interface](http://docs.oracle.com/javase/tutorial/java/concepts/interface.html), so you can use in all the classes. – VenomVendor Jun 15 '14 at 12:06
3 Answers
2
I think AsyncTask do use for in his class.Beacause This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers. AsyncTask must be subclassed to be used. The subclass will override at least one method (doInBackground(Params...)), and most often will override a second one (onPostExecute(Result).)
http://developer.android.com/reference/android/os/AsyncTask.html

Mahmudul Haque Khan
- 426
- 4
- 19
0
Yes you can .create a new asynctask class with your common operation. And you can create callback interface and your activity must implement interface to get appropriate callback of asynctask.
Android, can I put AsyncTask in a separate class and have a callback?
-
Interesting answer. May test this when I get a chance and if it works I think it's the solution. – zgc7009 Jun 15 '14 at 12:44