quartz/content/Obsidian Vault/android/back button.md
2022-06-07 14:39:39 -06:00

19 lines
550 B
Markdown

#cs240 #android
Sometimes the back button in the app bar is for going to a *parent* activity, not just the last one. Define that in the AndroidManifest.xml:
<activity
name..
label..
android:parentActivityName=".ui.MainActivity"
Use the following code right after setting up the app bar:
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
To make sure that the main activity isn't restarted upon return, write the following in the main activity's manifest entry.
<activity
name...
label...
android:launchMode="singleTop">