in Education by
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)

1 Answer

0 votes
by
i recompiled and ran with logs instead of debugger and ran ok with existing code. note sure if local glitch. thanks Pavan, "return null" killed the thread totally even with debugger on, but didn't go to onpostexecute for me that time.

Related questions

0 votes
    Consider a hypothetical method of an object that does stuff for you: public class DoesStuff { BackgroundWorker ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    9. Cancel button (x on formula bar) can be used to undo a cell entry after it has been completed (a) True (b) ... ) Alt+P (d) Ctrl+P Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    write about cancel,enter and insert function button in ms excel 2010 Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    You can cancel the previous action performed by clicking on the _______ button from __________ Select the correct answer from above options...
asked Dec 6, 2021 in Education by JackTerrance
0 votes
    You can cancel the previous action performed by clicking on the _______ button from __________ Select the correct answer from above options...
asked Dec 5, 2021 in Education by JackTerrance
0 votes
    You can cancel the previous action performed by clicking on the _______ button from __________ Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
0 votes
0 votes
    How can you cancel a form submission through client script?...
asked May 25, 2021 in Technology by JackTerrance
0 votes
    How can you cancel an Asynchronous postback?...
asked Dec 31, 2020 in Technology by JackTerrance
0 votes
    What is the name for space inside which a robot unit operates? (a) environment (b) spatial base (c) work envelope (d) exclusion zone Please answer the above question....
asked Oct 22, 2022 in Education by JackTerrance
0 votes
    I would like to manage a process inside a cmd file. My cmd will launch an other cmd file and i ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I am paginating users and in my view I have: I want to limit li.profile to 200 characters ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
0 votes
    I have a UITableView inside a UITableViewCell (Scrolling is disabled for the nested UITableView) Everything works ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    I have a UITableView inside a UITableViewCell (Scrolling is disabled for the nested UITableView) Everything works ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 26, 2022 in Education by JackTerrance
...