When using AsyncTask and doing doInBackground()
I sometimes get a result that stats that I don't want to go on to onPostExecute()
.
I tried to use cancel(true);
but it still goes into onPostExecute()
Thats my code:
@Override
protected LiveMatchDetails doInBackground(Void... params) {
try {
events = getLiveMatchEventsList(matchId, FetchPolicy.FROM_NETWORK);
} catch (Exception e) {
Log.e(TAG, "Error loading events", e);
try {
events = getLiveMatchEventsList(matchId, FetchPolicy.FROM_CACHE);
} catch (Exception e1) {
e1.printStackTrace();
cancel(true);
onProgressUpdate();
}
}
return events;
}
Is there a way to prevent the call to onPostExecute() from within the doInBAckground()?