Reputation: 199
This is theoretic question but I need some advice. I have complicated logic of switching between my activities. One part is easy: ActualActivity --> start next. The problem is with previousActivity <-- ActualActivity (by back button e.g.). What can I do if I can walk in cycle? And when I achieve last Activity of logic process and I need to finish last 4 Activities which precede this proces!? Naturally I don't want to call back on each of them.
This is one of reasons why I decide to call finish() on each activity by default. I overrode StartActivity and put there finish(). I also fixed set backIntent for each Activity. But sometimes it is not enough. Is it possible to send Intent some way to another Activity? For better understanding of my idea: intent.putExtra(BackIntent)
It is clear to me that it is not common and good solution. How can I manage "onPaused" activities which are not needed? How can I find out if activity is paused and call resume on it?
Thank you.
Upvotes: 0
Views: 87
Reputation: 2014
I think your problem can be resolve with "startactivityforresult"
//Activity A
private void someMethod()
{
this.startActivityForResult(intentForActivityB, 123456);
}
@Override
protected void onActivityResult(int request, int result, Intent intent)
{
if(request == 123456 && result == Activity.RESULT_OK)
this.finish();
super.onActivityResult(request, result, intent);
}
//Activity B
private void someMethod()
{
this.setResult(Activity.RESULT_OK);
this.finish();
}
this will close activity A when the Activity B is OK (setResult), an only in this case
Upvotes: 0
Reputation: 18243
I think you need to read documentation about Intent Flags:
This is how you can control all that is related to activity stack and storyboard.
Upvotes: 1