The question might be dumb but I'll ask it, for example I have 3 Activities, Activity 1,2,3.
Activity 1, I click a button, goes to Activity 2 Activity 2, I click a button, goes to Activity 3. Activity 3, I click the back button, I want it to go back to Activity 1. Any idea how to do it? Sorry Android Newbie. Thanks!
override onbackpressed method and just do like this:-
@Override
public void onBackPressed() {
Intent intent = new Intent(Activity3.this,
Activity1.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
}
Enjoy....!
In the android.manifest file make your second Activity..
android:excludeFromRecents="true"
android:launchMode="singleTask"
Hope this does the trick. if this does not work then you can try by setting Intent.setFlags
while you start the activity 2
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