In my android application, I have following requirement.
Activity A --> Activity B(Go to A Option) --> Activity C(Go To A Option,Go To B Option)
1) To Go To Activity A from Activity B i have used onBackPressed()
method.
2) To Go To Activity B from Activity C i have used onBackPressed()
method again.
those are working fine.
3) Now i want to go to Activity A from Activity C (without Intent calling).
How can i do this?
Edited 1:
Activity A is my Main activity i don't want restart the activity by using Intent.i want to resume Activity A from activity c.(like i did from activity B by using onBackPressed).
Edited 2(With Answer):
Ok guys. Thanks everyone for giving me your help on my question.finally i found a simple answer similar to @Paresh Mayani's answer.
Answer:
Intent a = new Intent(getApplicationContext(),ActivityA.class);
a.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(a);
i got this nice solution by using this link that solved my problem. thanks to everyone again and i really appreciate that.
I assume that you don't want to use Intent because whenever you use Intent for moving to activity A pressing Back key will move to the previous activity (activity C). In this case I would suggest you to include FLAG_ACTIVITY_CLEAR_TOP
flag. It will destroy all the previous activity and let you to move to Activity A.
Intent a = new Intent(this,A.class);
a.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(a);
Alternatively, you can try the FLAG_ACTIVITY_REORDER_TO_FRONT
flag instead, which will move to activity A without clearing any activity.
For more, check this.
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