Loading api/current.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -2601,6 +2601,7 @@ package android.app { method public void finish(); method public void finish(); method public void finishActivity(int); method public void finishActivity(int); method public void finishActivityFromChild(android.app.Activity, int); method public void finishActivityFromChild(android.app.Activity, int); method public void finishAffinity(); method public void finishFromChild(android.app.Activity); method public void finishFromChild(android.app.Activity); method public android.app.ActionBar getActionBar(); method public android.app.ActionBar getActionBar(); method public final android.app.Application getApplication(); method public final android.app.Application getApplication(); core/java/android/app/Activity.java +30 −0 Original line number Original line Diff line number Diff line Loading @@ -4092,6 +4092,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 * This is called when a child activity of this one calls its * {@link #finish} method. The default implementation simply calls * {@link #finish} method. The default implementation simply calls Loading core/java/android/app/ActivityManagerNative.java +22 −1 Original line number Original line Diff line number Diff line Loading @@ -243,6 +243,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; return true; } } case FINISH_ACTIVITY_AFFINITY_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); IBinder token = data.readStrongBinder(); boolean res = finishActivityAffinity(token); reply.writeNoException(); reply.writeInt(res ? 1 : 0); return true; } case WILL_ACTIVITY_BE_VISIBLE_TRANSACTION: { case WILL_ACTIVITY_BE_VISIBLE_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); data.enforceInterface(IActivityManager.descriptor); IBinder token = data.readStrongBinder(); IBinder token = data.readStrongBinder(); Loading Loading @@ -1866,6 +1875,18 @@ class ActivityManagerProxy implements IActivityManager data.recycle(); data.recycle(); reply.recycle(); reply.recycle(); } } public boolean finishActivityAffinity(IBinder token) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(token); mRemote.transact(FINISH_ACTIVITY_AFFINITY_TRANSACTION, data, reply, 0); reply.readException(); boolean res = reply.readInt() != 0; data.recycle(); reply.recycle(); return res; } public boolean willActivityBeVisible(IBinder token) throws RemoteException { public boolean willActivityBeVisible(IBinder token) throws RemoteException { Parcel data = Parcel.obtain(); Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); Parcel reply = Parcel.obtain(); Loading core/java/android/app/IActivityManager.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -72,6 +72,7 @@ public interface IActivityManager extends IInterface { public boolean finishActivity(IBinder token, int code, Intent data) public boolean finishActivity(IBinder token, int code, Intent data) throws RemoteException; throws RemoteException; public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException; public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException; public boolean finishActivityAffinity(IBinder token) throws RemoteException; public boolean willActivityBeVisible(IBinder token) throws RemoteException; public boolean willActivityBeVisible(IBinder token) throws RemoteException; public Intent registerReceiver(IApplicationThread caller, String callerPackage, public Intent registerReceiver(IApplicationThread caller, String callerPackage, IIntentReceiver receiver, IntentFilter filter, IIntentReceiver receiver, IntentFilter filter, Loading Loading @@ -590,4 +591,5 @@ public interface IActivityManager extends IInterface { int TARGET_TASK_AFFINITY_MATCHES_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+145; int TARGET_TASK_AFFINITY_MATCHES_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+145; int NAVIGATE_UP_TO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+146; int NAVIGATE_UP_TO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+146; int SET_LOCK_SCREEN_SHOWN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+147; int SET_LOCK_SCREEN_SHOWN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+147; int FINISH_ACTIVITY_AFFINITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+148; } } services/java/com/android/server/am/ActivityManagerService.java +9 −17 Original line number Original line Diff line number Diff line Loading @@ -2697,26 +2697,18 @@ public final class ActivityManagerService extends ActivityManagerNative public final void finishSubActivity(IBinder token, String resultWho, public final void finishSubActivity(IBinder token, String resultWho, int requestCode) { int requestCode) { synchronized(this) { synchronized(this) { ActivityRecord self = mMainStack.isInStackLocked(token); if (self == null) { return; } final long origId = Binder.clearCallingIdentity(); final long origId = Binder.clearCallingIdentity(); mMainStack.finishSubActivityLocked(token, resultWho, requestCode); int i; Binder.restoreCallingIdentity(origId); for (i=mMainStack.mHistory.size()-1; i>=0; i--) { ActivityRecord r = (ActivityRecord)mMainStack.mHistory.get(i); if (r.resultTo == self && r.requestCode == requestCode) { if ((r.resultWho == null && resultWho == null) || (r.resultWho != null && r.resultWho.equals(resultWho))) { mMainStack.finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "request-sub"); } } } } } public boolean finishActivityAffinity(IBinder token) { synchronized(this) { final long origId = Binder.clearCallingIdentity(); boolean res = mMainStack.finishActivityAffinityLocked(token); Binder.restoreCallingIdentity(origId); Binder.restoreCallingIdentity(origId); return res; } } } } Loading Loading
api/current.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -2601,6 +2601,7 @@ package android.app { method public void finish(); method public void finish(); method public void finishActivity(int); method public void finishActivity(int); method public void finishActivityFromChild(android.app.Activity, int); method public void finishActivityFromChild(android.app.Activity, int); method public void finishAffinity(); method public void finishFromChild(android.app.Activity); method public void finishFromChild(android.app.Activity); method public android.app.ActionBar getActionBar(); method public android.app.ActionBar getActionBar(); method public final android.app.Application getApplication(); method public final android.app.Application getApplication();
core/java/android/app/Activity.java +30 −0 Original line number Original line Diff line number Diff line Loading @@ -4092,6 +4092,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 * This is called when a child activity of this one calls its * {@link #finish} method. The default implementation simply calls * {@link #finish} method. The default implementation simply calls Loading
core/java/android/app/ActivityManagerNative.java +22 −1 Original line number Original line Diff line number Diff line Loading @@ -243,6 +243,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; return true; } } case FINISH_ACTIVITY_AFFINITY_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); IBinder token = data.readStrongBinder(); boolean res = finishActivityAffinity(token); reply.writeNoException(); reply.writeInt(res ? 1 : 0); return true; } case WILL_ACTIVITY_BE_VISIBLE_TRANSACTION: { case WILL_ACTIVITY_BE_VISIBLE_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); data.enforceInterface(IActivityManager.descriptor); IBinder token = data.readStrongBinder(); IBinder token = data.readStrongBinder(); Loading Loading @@ -1866,6 +1875,18 @@ class ActivityManagerProxy implements IActivityManager data.recycle(); data.recycle(); reply.recycle(); reply.recycle(); } } public boolean finishActivityAffinity(IBinder token) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(token); mRemote.transact(FINISH_ACTIVITY_AFFINITY_TRANSACTION, data, reply, 0); reply.readException(); boolean res = reply.readInt() != 0; data.recycle(); reply.recycle(); return res; } public boolean willActivityBeVisible(IBinder token) throws RemoteException { public boolean willActivityBeVisible(IBinder token) throws RemoteException { Parcel data = Parcel.obtain(); Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); Parcel reply = Parcel.obtain(); Loading
core/java/android/app/IActivityManager.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -72,6 +72,7 @@ public interface IActivityManager extends IInterface { public boolean finishActivity(IBinder token, int code, Intent data) public boolean finishActivity(IBinder token, int code, Intent data) throws RemoteException; throws RemoteException; public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException; public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException; public boolean finishActivityAffinity(IBinder token) throws RemoteException; public boolean willActivityBeVisible(IBinder token) throws RemoteException; public boolean willActivityBeVisible(IBinder token) throws RemoteException; public Intent registerReceiver(IApplicationThread caller, String callerPackage, public Intent registerReceiver(IApplicationThread caller, String callerPackage, IIntentReceiver receiver, IntentFilter filter, IIntentReceiver receiver, IntentFilter filter, Loading Loading @@ -590,4 +591,5 @@ public interface IActivityManager extends IInterface { int TARGET_TASK_AFFINITY_MATCHES_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+145; int TARGET_TASK_AFFINITY_MATCHES_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+145; int NAVIGATE_UP_TO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+146; int NAVIGATE_UP_TO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+146; int SET_LOCK_SCREEN_SHOWN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+147; int SET_LOCK_SCREEN_SHOWN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+147; int FINISH_ACTIVITY_AFFINITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+148; } }
services/java/com/android/server/am/ActivityManagerService.java +9 −17 Original line number Original line Diff line number Diff line Loading @@ -2697,26 +2697,18 @@ public final class ActivityManagerService extends ActivityManagerNative public final void finishSubActivity(IBinder token, String resultWho, public final void finishSubActivity(IBinder token, String resultWho, int requestCode) { int requestCode) { synchronized(this) { synchronized(this) { ActivityRecord self = mMainStack.isInStackLocked(token); if (self == null) { return; } final long origId = Binder.clearCallingIdentity(); final long origId = Binder.clearCallingIdentity(); mMainStack.finishSubActivityLocked(token, resultWho, requestCode); int i; Binder.restoreCallingIdentity(origId); for (i=mMainStack.mHistory.size()-1; i>=0; i--) { ActivityRecord r = (ActivityRecord)mMainStack.mHistory.get(i); if (r.resultTo == self && r.requestCode == requestCode) { if ((r.resultWho == null && resultWho == null) || (r.resultWho != null && r.resultWho.equals(resultWho))) { mMainStack.finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "request-sub"); } } } } } public boolean finishActivityAffinity(IBinder token) { synchronized(this) { final long origId = Binder.clearCallingIdentity(); boolean res = mMainStack.finishActivityAffinityLocked(token); Binder.restoreCallingIdentity(origId); Binder.restoreCallingIdentity(origId); return res; } } } } Loading