I want to do something simple on android app. How is it possible to go back to a previous activity.
What code do I need to go back to previous activity
Just call these method to finish current activity or to go back by onBackPressed
finish();
OR
onBackPressed();
After that you have two way to back from current activity to previous activity:
Simply call: finish()
under button click listener,
Or
Override the following method to back using system back button:
@Override
public void onBackPressed() {
super.onBackPressed();
}
Got the same problem and
finish(); OR super.onBackPressed();
worked fine for me, both worked same, but no luck with return
Try this is act as you have to press the back button
finish();
super.onBackPressed();
I suggest the NavUtils.navigateUpFromSameTask(), it's easy and very simple, you can learn it from the google developer.Wish I could help you!
Try Activity#finish(). This is more or less what the back button does by default.