Configure "Activity" hierarchy in "AndroidManifest"

4

I'm trying to understand how can I set a Activity to return to Activity earlier in AndroidManifest ?

    
asked by anonymous 28.10.2014 / 00:00

2 answers

5

The Activity hierarchy is set in manifest , where we can define the expected navigation between them:

Example:

<activity
    android:name=".MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name=".ResultActivity"
    android:parentActivityName=".MainActivity">
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value=".MainActivity"/>
</activity>

In the example above, the MainActivity is set as the predecessor of ResultActivity .

This subject is covered in some detail in the training examples in:

Preserve Navigation When Starting Activity (English)     

28.10.2014 / 09:20
1

I did not understand your right question but all Activity 's will exit Activity MAIN , when you call the method onBackPressed() (English) it will close the current one and return to what it was called.

Example:

MAIN --> Activity1 --> Activity2 \/

MAIN <-- Activity1 <-- Activity2 

Next: new Intent(); (English)

Return: onBackPressed(); (English)

Remembering that this is done automatically, you do not need to onBackPressed() unless you want some other function.

    
28.10.2014 / 06:24