Articles → ANDROID → Back Button In Android

Back Button In Android






Example




  1. MainActivity
  2. SecondActivity




  1. Add a button on MainActivity with the text ‘Navigate’. On click of Navigate button, add the following code
  2. public void Navigate(View view) {
        Intent i = new Intent(getApplicationContext(), SecondActivity.class);
        startActivity(i);
    }


  3. In AndroidManifest.xml, add the following code in SecondActivity
  4. <activity android:name=".SecondActivity" android:parentActivityName=".MainActivity" >
    	<meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity"></meta-data>
    </activity>
    




Picture showing the back button in android application
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Thursday, November 28, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250