Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Stop Asyn Task at onPreExecute?

Tags:

json

android

xml

I'm checking for internet connection status in onPreExecute() and If there is no internet connection, it should not execute the doInBackground() and onPostExecute()

new getStatus().execute();

private class getStatus extends AsyncTask<Void, Void, Void> {
like image 721
Uday Avatar asked Mar 14 '16 08:03

Uday


1 Answers

You set a flag in the AsyncTask in onPreExecute. Check that flag in the other two functions, and immediately return if the flag is true.

like image 87
Gabe Sechan Avatar answered Oct 03 '22 06:10

Gabe Sechan