When I click the back button Android goes to the previous activity. Is it possible to set for every activity a custom (back) activity or to set the back button to the home menue of the app?
Help or hints would be great :)
Android activities are stored in the activity stack. Going back to a previous activity could mean two things. You opened the new activity from another activity with startActivityForResult. In that case you can just call the finishActivity() function from your code and it'll take you back to the previous activity.
2 Answers. Show activity on this post. and when you click on back button in the toolbar programmatically go back to the previous fragment using following code. Show activity on this post.
You will have to override onBackPressed() from your activity:
@Override
public void onBackPressed()
{
super.onBackPressed();
startActivity(new Intent(ThisActivity.this, NextActivity.class));
finish();
}
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