summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2021-06-15 18:33:01 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-06-15 18:33:01 +0000
commit1e40e4068d4a030f12e2bb7df94fa3518131863d (patch)
tree19ed7251095aac5541fe38d8810fde247624cc15
parent0a9650dcde5457fb34832d93f179d91c6df4a4ee (diff)
parentc257fb9ee120c51867eb953dd59c9d0edcf322d1 (diff)
Merge "Update docs for onBackPressed" into sc-dev
-rw-r--r--core/java/android/app/Activity.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 854c9f2a5b3a..db5dcc5c264b 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -3866,9 +3866,26 @@ public class Activity extends ContextThemeWrapper
}
/**
- * Called when the activity has detected the user's press of the back
- * key. The default implementation simply finishes the current activity,
- * but you can override this to do whatever you want.
+ * Called when the activity has detected the user's press of the back key. The default
+ * implementation depends on the platform version:
+ *
+ * <ul>
+ * <li>On platform versions prior to {@link android.os.Build.VERSION_CODES#S}, it
+ * finishes the current activity, but you can override this to do whatever you want.
+ *
+ * <li><p>Starting with platform version {@link android.os.Build.VERSION_CODES#S}, for
+ * activities that are the root activity of the task and also declare an
+ * {@link android.content.IntentFilter} with {@link Intent#ACTION_MAIN} and
+ * {@link Intent#CATEGORY_LAUNCHER} in the manifest, the current activity and its
+ * task will be moved to the back of the activity stack instead of being finished.
+ * Other activities will simply be finished.
+ *
+ * <p>If you target version {@link android.os.Build.VERSION_CODES#S} or later and
+ * override this method, it is strongly recommended to call through to the superclass
+ * implementation after you finish handling navigation within the app.
+ * </ul>
+ *
+ * @see #moveTaskToBack(boolean)
*/
public void onBackPressed() {
if (mActionBar != null && mActionBar.collapseActionView()) {