I am running an AsyncTask to process multiple images. I am only able to detect that the operation should stop/cancel during run time and have to terminate the thread and return to the previous intent. How can I stop the thread running and return to the previous activity. Code so far exits current loop but continues to run and gives errors and undesired results
private class processImagesThread extends AsyncTask {
@Override
protected Bitmap doInBackground(String... params) {
for (int i = 0; i < ArrayUris.size(); i++) {
if(failCondition){
Intent resultIntent = new Intent();
setResult(Activity.RESULT_CANCELED);//normally return ok and a URI
this.cancel(true);
finish();
break;
}
}
//further processing continues after failcondition
}
@Override
protected void onCancelled()
{
super.onCancelled();
Intent resultIntent = new Intent();
setResult(Activity.RESULT_CANCELED);
}
}
//previous intent
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(resultCode == RESULT_CANCELED) { //Toast to user}}
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)