Articles → ANDROID → Back Button In Android
Back Button In Android
Example
- MainActivity
- SecondActivity
- Add a button on MainActivity with the text ‘Navigate’. On click of Navigate button, add the following code
public void Navigate(View view) {
Intent i = new Intent(getApplicationContext(), SecondActivity.class);
startActivity(i);
}
- In AndroidManifest.xml, add the following code in SecondActivity
<activity android:name=".SecondActivity" android:parentActivityName=".MainActivity" >
<meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity"></meta-data>
</activity>
Click to Enlarge