File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes may have two AsyncTask classes in ONE java file(=Activity file)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "may have two AsyncTask classes in ONE java file(=Activity file)? " Watch "may have two AsyncTask classes in ONE java file(=Activity file)? " New topic
Author

may have two AsyncTask classes in ONE java file(=Activity file)?

Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 402
may have two AsyncTask classes in ONE java file(=Activity file)?

private class SaveSharedPreferences extends AsyncTask<String, Object, Object>
{

}

private class LoadSharedPreferences extends AsyncTask<Object, Object, SharedPreferences>
{

}
Przemek Boryka
Ranch Hand

Joined: Dec 06, 2011
Posts: 51

Hi !

In my opinion, You can have as many asynctask as you want, its becous of one fact:
AsyncTask allows you to perform asynchronous work on your user interface. It performs the blocking operations in a worker thread and then publishes the results on the UI thread, without requiring you to handle threads and/or handlers yourself.

The second fact is :
When first introduced, AsyncTasks were executed serially on a single background thread. Starting with DONUT, this was changed to a pool of threads allowing multiple tasks to operate in parallel. Starting with HONEYCOMB, tasks are executed on a single thread to avoid common application errors caused by parallel execution. ;)

I have a little experience with AsyncTask, so my answer for your question can be wrong.

Bye Sorry for my english !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: may have two AsyncTask classes in ONE java file(=Activity file)?
 
Similar Threads
doubt on inheritance?
What will be the name of .java file?
How to pass string from TCP server (a Runnable) to main activity (in Android)?
Null pointer exception probably due to synchronisation issues; problem in starting activity
Reading from a socket