Can't Stop/restart Asynctask
Please help. I can restart the AsyncTask. App crashes every time, when second call to updatePoi(). Here is my code: I'm checking status of task and set cancel(true). public void u
Solution 1:
An AsyncTask
instance can only be called once. To make a second call, you need to create a new instance.
Solution 2:
You can't restart a task. Each task object may only be executed once:
The task can be executed only once (an exception will be thrown if a second execution is attempted.)
So create a new object each time you execute it, don't use the same object.
Solution 3:
try
returnnull;
final code
@OverrideprotectedVoid doInBackground(Void... voids) {
Application app = (Application)getApplication();
Log.d(TAG, "exits count = " + app.getExits().size());
GeoPoint pointToNavigate = null;
for (Exit exit : app.getExits()) {
for (Poi poi : exit.getPoi()) {
if (isCancelled()){
returnnull;
}
//some code here
}
}
//small code herereturnnull;
}
Post a Comment for "Can't Stop/restart Asynctask"