Create an object of the task and execute the same task as following.
UpdateCoin updatecoin = new UpdateCoin();
if (updatecoin.getStatus() == AsyncTask.Status.PENDING) {
}
if (updatecoin.getStatus() == AsyncTask.Status.RUNNING) {
}
if (updatecoin.getStatus() == AsyncTask.Status.FINISHED) {
Runnable myRunner = new Runnable() {
public void run() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
new UpdateCoin().executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR, coin,
LevelUpBonus[level - 1]);
} else {
new UpdateCoin().executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR, coin,
LevelUpBonus[level - 1]);
}
}
};
myHandler.post(myRunner);
}
Search This Blog
Showing posts with label THREAD_POOL_EXECUTOR. Show all posts
Showing posts with label THREAD_POOL_EXECUTOR. Show all posts
Thursday, August 29, 2013
Tuesday, July 16, 2013
Ecxecute two Different AsyncTask parallel in android
If you want to ecxecute the two different asynctask to be ecxecute parallelly then you shoul use the second async task ecxecution like below. UpdateCoin is the Async task.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
new UpdateCoin().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
mPref.getInt("UserCoin", 0), CalculatedCoin);
} else {
new UpdateCoin().execute(mPref.getInt("UserCoin", 0), CalculatedCoin);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
new UpdateCoin().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
mPref.getInt("UserCoin", 0), CalculatedCoin);
} else {
new UpdateCoin().execute(mPref.getInt("UserCoin", 0), CalculatedCoin);
}
Labels:
AsyncTask,
THREAD_POOL_EXECUTOR
Subscribe to:
Posts (Atom)