I'm trying to understand how can I set a Activity
to return to Activity
earlier in AndroidManifest
?
I'm trying to understand how can I set a Activity
to return to Activity
earlier in AndroidManifest
?
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:
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.