summaryrefslogtreecommitdiff
path: root/core/java/android/app/Activity.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-04-26 18:56:09 -0700
committerDianne Hackborn <hackbod@google.com>2012-04-26 18:56:09 -0700
commitecc5a9cca000b62d2a649b795460fd791a206a89 (patch)
tree02d52fd9ae44a0be72dda0a2890001f9f8fae118 /core/java/android/app/Activity.java
parent16fb5d444cea1c978257807910b96d4e47b78dce (diff)
Add new Activity.finishAffinity() method.
It's cool! Change-Id: I9fdcd9535b7f1ca2b311d3a1b23e5d058977b095
Diffstat (limited to 'core/java/android/app/Activity.java')
-rw-r--r--core/java/android/app/Activity.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 35bc7ff925a5..4add7f40455b 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -4093,6 +4093,36 @@ public class Activity extends ContextThemeWrapper
}
/**
+ * Finish this activity as well as all activities immediately below it
+ * in the current task that have the same affinity. This is typically
+ * used when an application can be launched on to another task (such as
+ * from an ACTION_VIEW of a content type it understands) and the user
+ * has used the up navigation to switch out of the current task and in
+ * to its own task. In this case, if the user has navigated down into
+ * any other activities of the second application, all of those should
+ * be removed from the original task as part of the task switch.
+ *
+ * <p>Note that this finish does <em>not</em> allow you to deliver results
+ * to the previous activity, and an exception will be thrown if you are trying
+ * to do so.</p>
+ */
+ public void finishAffinity() {
+ if (mParent != null) {
+ throw new IllegalStateException("Can not be called from an embedded activity");
+ }
+ if (mResultCode != RESULT_CANCELED || mResultData != null) {
+ throw new IllegalStateException("Can not be called to deliver a result");
+ }
+ try {
+ if (ActivityManagerNative.getDefault().finishActivityAffinity(mToken)) {
+ mFinished = true;
+ }
+ } catch (RemoteException e) {
+ // Empty
+ }
+ }
+
+ /**
* This is called when a child activity of this one calls its
* {@link #finish} method. The default implementation simply calls
* finish() on this activity (the parent), finishing the entire group.