Wednesday, 1 July 2015

Android: Go back to previous activity



These three functions can do the same thing:

finish();
onBackPressed();
NavUtils.navigateUpFromSameTask(this);


Explanation:

finish();    //this one will trigger parent activity's onActivityResult() function.
onBackPressed();   //same as back button clicked.

NavUtils.navigateUpFromSameTask(this);  // you must set parent activity in AndroidManifest.xml of current activity.









http://stackoverflow.com/questions/4038479/android-go-back-to-previous-activity

No comments:

Post a comment