I would like to check for a variable in MainActivity while an AsyncTask created from it is running in the background, then end the AsyncTask when this variable is set to a certain value let's say to true;
MainActivity
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
new MyTask(this).execute();
}
MyTask
public class MyTask extends AsyncTask<Void, Void, Void>
{
@Override
protected Void doInBackground(Void... ignore)
{
//check for MainActivity variable then exit or PostExecute when this variable is set to true?
}
}