Android up navigation

In your application that contains more than one activity, it is a good idea to provide up navigation from an activity to its parent activity. By doing this, your application provides better user experience. This Android shows how to achieve this goal.
To provide the up navigation in an activity, first you need to declare its parent activity in the AndroidManifest.xml file. By doing so, the system can look up the parent activity in the AndroidManifest.xml file. If your application target Android 4.1 or higher, you can declare the parent activity using the android:parentActivityName attribute in the <activity> element. If your application supports Android 4.0 or lower, you need to add a <meta-data>element inside activity. Then assign to the android:name and the parent activity (as specified with the android:parentActivityName attribute) to the android:value attribute.

        android:label="@string/app_name" >
           <action android:name="android.intent.action.MAIN" />

           <category android:name="android.intent.category.LAUNCHER" />

        android:parentActivityName=".MainActivity" >
           android:value="com.example.androidexample.MainActivity" />

In the action bar, you see the up navigation that consisting of the app icon and a left-point caret. If now you are on the SecondActivity activity and press the up navigation, the application will take you back to the MainActivity. You should note that to open the SecondActivity activity from the MainActivity, you need to construct the Intent object and call the startActivity() method passing the Intent object as parameter.

Intent intent=new Intent(this,SecondActivity.class);


Posted by: Dara | post date: 10-09-2014 | Subject: Android Apps Development

write programming tip

This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.