Below I'm showing the flow on how I want to navigate my Activities
:
I tried writing the following code inside D
and E
:
Intent list = new Intent(AddComplaint.this, B.class);
list.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(list);
However, I'm facing two issues:
B
gets launched it shows a grey screen for a while, then it gets loaded.B
it exits out of the application rather than going to A
(the dashbord).How can I fix this?
I believe you can achieve what you want by using FLAG_ACTIVITY_CLEAR_TOP. If you send an Intent using this flag, it will be delivered to the existing Activity B, and any activities above B on the stack (C, D/E) will be finished.
Using FLAG_ACTIVITY_CLEAR_TASK will finish all previous activities on the stack, which would make B the only remaining activity - explaining why you exit the app when clicking back. Your grey background is unrelated to activity management and indicates the activity is simply taking a while to call onCreate().
Example code:
Intent list = new Intent(AddComplaint.this, B.class);
list.setFlags
(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(list);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With