简体   繁体   中英

How to handle onActivityResult?

I am blocking in onActivity result.

Activity A startActivityForResult() to Activity B, Some business reason i am removing activity B and moving to till Activity F. From Activity F have to send setResult() to Activity A same time i have to clear stacks while moving to Activity A.

How to handle this scenario?

We can use a flag from Intent class (didn't try myself) - Intent.FLAG_ACTIVITY_FORWARD_RESULT

Right before calling finish() in each of your middle actvities, you must be making a call to startActivity(intent) . Pass this flag to this intent :

showC.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);

In your last activity, do the regular setResult() ceremony. And then try to get result in your first activity as usual.

using intent start ActivityF and pass result to ActivityA using intent.putExtra

Intent intent = new Intent(ActivityF.this, ActivityA.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("RESULT", "result to ActivityA");
startActivity(intent);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM