Search This Blog

Thursday, August 29, 2013

Run the same AsyncTask after completing itself.

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);
                    }

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.