Add new "options" argument to all startActivity APIs.
This will be used to allow new features to be requested... such as,
say, a special kind of animation. Right now there are no options
defined.
Change-Id: I4eb6f27275cdd4bf186f6da316ab93a2372ad4b7
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 0f2aa46..dc12acd 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -3166,42 +3166,60 @@
}
/**
+ * Same as calling {@link #startActivityForResult(Intent, int, Bundle)}
+ * with no options.
+ *
+ * @param intent The intent to start.
+ * @param requestCode If >= 0, this code will be returned in
+ * onActivityResult() when the activity exits.
+ *
+ * @throws android.content.ActivityNotFoundException
+ *
+ * @see #startActivity
+ */
+ public void startActivityForResult(Intent intent, int requestCode) {
+ startActivityForResult(intent, requestCode, null);
+ }
+
+ /**
* Launch an activity for which you would like a result when it finished.
* When this activity exits, your
* onActivityResult() method will be called with the given requestCode.
* Using a negative requestCode is the same as calling
* {@link #startActivity} (the activity is not launched as a sub-activity).
- *
+ *
* <p>Note that this method should only be used with Intent protocols
* that are defined to return a result. In other protocols (such as
* {@link Intent#ACTION_MAIN} or {@link Intent#ACTION_VIEW}), you may
* not get the result when you expect. For example, if the activity you
* are launching uses the singleTask launch mode, it will not run in your
* task and thus you will immediately receive a cancel result.
- *
+ *
* <p>As a special case, if you call startActivityForResult() with a requestCode
* >= 0 during the initial onCreate(Bundle savedInstanceState)/onResume() of your
* activity, then your window will not be displayed until a result is
* returned back from the started activity. This is to avoid visible
* flickering when redirecting to another activity.
- *
+ *
* <p>This method throws {@link android.content.ActivityNotFoundException}
* if there was no Activity found to run the given Intent.
- *
+ *
* @param intent The intent to start.
* @param requestCode If >= 0, this code will be returned in
* onActivityResult() when the activity exits.
- *
+ * @param options Additional options for how the Activity should be started.
+ * May be null if there are no options.
+ *
* @throws android.content.ActivityNotFoundException
- *
+ *
* @see #startActivity
*/
- public void startActivityForResult(Intent intent, int requestCode) {
+ public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
if (mParent == null) {
Instrumentation.ActivityResult ar =
mInstrumentation.execStartActivity(
this, mMainThread.getApplicationThread(), mToken, this,
- intent, requestCode);
+ intent, requestCode, options);
if (ar != null) {
mMainThread.sendActivityResult(
mToken, mEmbeddedID, requestCode, ar.getResultCode(),
@@ -3218,11 +3236,39 @@
mStartedActivity = true;
}
} else {
- mParent.startActivityFromChild(this, intent, requestCode);
+ if (options != null) {
+ mParent.startActivityFromChild(this, intent, requestCode, options);
+ } else {
+ // Note we want to go through this method for compatibility with
+ // existing applications that may have overridden it.
+ mParent.startActivityFromChild(this, intent, requestCode);
+ }
}
}
/**
+ * Same as calling {@link #startIntentSenderForResult(IntentSender, int,
+ * Intent, int, int, int, Bundle)} with no options.
+ *
+ * @param intent The IntentSender to launch.
+ * @param requestCode If >= 0, this code will be returned in
+ * onActivityResult() when the activity exits.
+ * @param fillInIntent If non-null, this will be provided as the
+ * intent parameter to {@link IntentSender#sendIntent}.
+ * @param flagsMask Intent flags in the original IntentSender that you
+ * would like to change.
+ * @param flagsValues Desired values for any bits set in
+ * <var>flagsMask</var>
+ * @param extraFlags Always set to 0.
+ */
+ public void startIntentSenderForResult(IntentSender intent, int requestCode,
+ Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
+ throws IntentSender.SendIntentException {
+ startIntentSenderForResult(intent, requestCode, fillInIntent, flagsMask,
+ flagsValues, extraFlags, null);
+ }
+
+ /**
* Like {@link #startActivityForResult(Intent, int)}, but allowing you
* to use a IntentSender to describe the activity to be started. If
* the IntentSender is for an activity, that activity will be started
@@ -3241,21 +3287,29 @@
* @param flagsValues Desired values for any bits set in
* <var>flagsMask</var>
* @param extraFlags Always set to 0.
+ * @param options Additional options for how the Activity should be started.
+ * May be null if there are no options.
*/
public void startIntentSenderForResult(IntentSender intent, int requestCode,
- Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
- throws IntentSender.SendIntentException {
+ Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
+ Bundle options) throws IntentSender.SendIntentException {
if (mParent == null) {
startIntentSenderForResultInner(intent, requestCode, fillInIntent,
- flagsMask, flagsValues, this);
+ flagsMask, flagsValues, this, options);
+ } else if (options != null) {
+ mParent.startIntentSenderFromChild(this, intent, requestCode,
+ fillInIntent, flagsMask, flagsValues, extraFlags, options);
} else {
+ // Note we want to go through this call for compatibility with
+ // existing applications that may have overridden the method.
mParent.startIntentSenderFromChild(this, intent, requestCode,
fillInIntent, flagsMask, flagsValues, extraFlags);
}
}
private void startIntentSenderForResultInner(IntentSender intent, int requestCode,
- Intent fillInIntent, int flagsMask, int flagsValues, Activity activity)
+ Intent fillInIntent, int flagsMask, int flagsValues, Activity activity,
+ Bundle options)
throws IntentSender.SendIntentException {
try {
String resolvedType = null;
@@ -3266,8 +3320,8 @@
int result = ActivityManagerNative.getDefault()
.startActivityIntentSender(mMainThread.getApplicationThread(), intent,
fillInIntent, resolvedType, mToken, activity.mEmbeddedID,
- requestCode, flagsMask, flagsValues);
- if (result == IActivityManager.START_CANCELED) {
+ requestCode, flagsMask, flagsValues, options);
+ if (result == ActivityManager.START_CANCELED) {
throw new IntentSender.SendIntentException();
}
Instrumentation.checkStartActivityResult(result, null);
@@ -3286,6 +3340,22 @@
}
/**
+ * Same as {@link #startActivity(Intent, Bundle)} with no options
+ * specified.
+ *
+ * @param intent The intent to start.
+ *
+ * @throws android.content.ActivityNotFoundException
+ *
+ * @see {@link #startActivity(Intent, Bundle)}
+ * @see #startActivityForResult
+ */
+ @Override
+ public void startActivity(Intent intent) {
+ startActivity(intent, null);
+ }
+
+ /**
* Launch a new activity. You will not receive any information about when
* the activity exits. This implementation overrides the base version,
* providing information about
@@ -3298,14 +3368,39 @@
* if there was no Activity found to run the given Intent.
*
* @param intent The intent to start.
+ * @param options Additional options for how the Activity should be started.
+ * May be null if there are no options.
*
* @throws android.content.ActivityNotFoundException
- *
+ *
+ * @see {@link #startActivity(Intent)}
* @see #startActivityForResult
*/
@Override
- public void startActivity(Intent intent) {
- startActivityForResult(intent, -1);
+ public void startActivity(Intent intent, Bundle options) {
+ if (options != null) {
+ startActivityForResult(intent, -1, options);
+ } else {
+ // Note we want to go through this call for compatibility with
+ // applications that may have overridden the method.
+ startActivityForResult(intent, -1);
+ }
+ }
+
+ /**
+ * Same as {@link #startActivities(Intent[], Bundle)} with no options
+ * specified.
+ *
+ * @param intents The intents to start.
+ *
+ * @throws android.content.ActivityNotFoundException
+ *
+ * @see {@link #startActivities(Intent[], Bundle)}
+ * @see #startActivityForResult
+ */
+ @Override
+ public void startActivities(Intent[] intents) {
+ startActivities(intents, null);
}
/**
@@ -3321,22 +3416,23 @@
* if there was no Activity found to run the given Intent.
*
* @param intents The intents to start.
+ * @param options Additional options for how the Activity should be started.
+ * May be null if there are no options.
*
* @throws android.content.ActivityNotFoundException
*
+ * @see {@link #startActivities(Intent[])}
* @see #startActivityForResult
*/
@Override
- public void startActivities(Intent[] intents) {
+ public void startActivities(Intent[] intents, Bundle options) {
mInstrumentation.execStartActivities(this, mMainThread.getApplicationThread(),
- mToken, this, intents);
+ mToken, this, intents, options);
}
/**
- * Like {@link #startActivity(Intent)}, but taking a IntentSender
- * to start; see
- * {@link #startIntentSenderForResult(IntentSender, int, Intent, int, int, int)}
- * for more information.
+ * Same as calling {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)}
+ * with no options.
*
* @param intent The IntentSender to launch.
* @param fillInIntent If non-null, this will be provided as the
@@ -3350,8 +3446,58 @@
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
throws IntentSender.SendIntentException {
- startIntentSenderForResult(intent, -1, fillInIntent, flagsMask,
- flagsValues, extraFlags);
+ startIntentSender(intent, fillInIntent, flagsMask, flagsValues,
+ extraFlags, null);
+ }
+
+ /**
+ * Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender
+ * to start; see
+ * {@link #startIntentSenderForResult(IntentSender, int, Intent, int, int, int, Bundle)}
+ * for more information.
+ *
+ * @param intent The IntentSender to launch.
+ * @param fillInIntent If non-null, this will be provided as the
+ * intent parameter to {@link IntentSender#sendIntent}.
+ * @param flagsMask Intent flags in the original IntentSender that you
+ * would like to change.
+ * @param flagsValues Desired values for any bits set in
+ * <var>flagsMask</var>
+ * @param extraFlags Always set to 0.
+ * @param options Additional options for how the Activity should be started.
+ * May be null if there are no options.
+ */
+ public void startIntentSender(IntentSender intent,
+ Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
+ Bundle options) throws IntentSender.SendIntentException {
+ if (options != null) {
+ startIntentSenderForResult(intent, -1, fillInIntent, flagsMask,
+ flagsValues, extraFlags, options);
+ } else {
+ // Note we want to go through this call for compatibility with
+ // applications that may have overridden the method.
+ startIntentSenderForResult(intent, -1, fillInIntent, flagsMask,
+ flagsValues, extraFlags);
+ }
+ }
+
+ /**
+ * Same as calling {@link #startActivityIfNeeded(Intent, int, Bundle)}
+ * with no options.
+ *
+ * @param intent The intent to start.
+ * @param requestCode If >= 0, this code will be returned in
+ * onActivityResult() when the activity exits, as described in
+ * {@link #startActivityForResult}.
+ *
+ * @return If a new activity was launched then true is returned; otherwise
+ * false is returned and you must handle the Intent yourself.
+ *
+ * @see #startActivity
+ * @see #startActivityForResult
+ */
+ public boolean startActivityIfNeeded(Intent intent, int requestCode) {
+ return startActivityIfNeeded(intent, requestCode, null);
}
/**
@@ -3374,6 +3520,8 @@
* @param requestCode If >= 0, this code will be returned in
* onActivityResult() when the activity exits, as described in
* {@link #startActivityForResult}.
+ * @param options Additional options for how the Activity should be started.
+ * May be null if there are no options.
*
* @return If a new activity was launched then true is returned; otherwise
* false is returned and you must handle the Intent yourself.
@@ -3381,17 +3529,17 @@
* @see #startActivity
* @see #startActivityForResult
*/
- public boolean startActivityIfNeeded(Intent intent, int requestCode) {
+ public boolean startActivityIfNeeded(Intent intent, int requestCode, Bundle options) {
if (mParent == null) {
- int result = IActivityManager.START_RETURN_INTENT_TO_CALLER;
+ int result = ActivityManager.START_RETURN_INTENT_TO_CALLER;
try {
intent.setAllowFds(false);
result = ActivityManagerNative.getDefault()
.startActivity(mMainThread.getApplicationThread(),
intent, intent.resolveTypeIfNeeded(getContentResolver()),
- null, 0,
- mToken, mEmbeddedID, requestCode, true /* onlyIfNeeded */,
- false, false, null, null, false);
+ mToken, mEmbeddedID, requestCode,
+ ActivityManager.START_FLAG_ONLY_IF_NEEDED, null, null,
+ options);
} catch (RemoteException e) {
// Empty
}
@@ -3408,7 +3556,7 @@
// activity is finished, no matter what happens to it.
mStartedActivity = true;
}
- return result != IActivityManager.START_RETURN_INTENT_TO_CALLER;
+ return result != ActivityManager.START_RETURN_INTENT_TO_CALLER;
}
throw new UnsupportedOperationException(
@@ -3416,6 +3564,24 @@
}
/**
+ * Same as calling {@link #startNextMatchingActivity(Intent, Bundle)} with
+ * no options.
+ *
+ * @param intent The intent to dispatch to the next activity. For
+ * correct behavior, this must be the same as the Intent that started
+ * your own activity; the only changes you can make are to the extras
+ * inside of it.
+ *
+ * @return Returns a boolean indicating whether there was another Activity
+ * to start: true if there was a next activity to start, false if there
+ * wasn't. In general, if true is returned you will then want to call
+ * finish() on yourself.
+ */
+ public boolean startNextMatchingActivity(Intent intent) {
+ return startNextMatchingActivity(intent, null);
+ }
+
+ /**
* Special version of starting an activity, for use when you are replacing
* other activity components. You can use this to hand the Intent off
* to the next Activity that can handle it. You typically call this in
@@ -3425,18 +3591,20 @@
* correct behavior, this must be the same as the Intent that started
* your own activity; the only changes you can make are to the extras
* inside of it.
+ * @param options Additional options for how the Activity should be started.
+ * May be null if there are no options.
*
* @return Returns a boolean indicating whether there was another Activity
* to start: true if there was a next activity to start, false if there
* wasn't. In general, if true is returned you will then want to call
* finish() on yourself.
*/
- public boolean startNextMatchingActivity(Intent intent) {
+ public boolean startNextMatchingActivity(Intent intent, Bundle options) {
if (mParent == null) {
try {
intent.setAllowFds(false);
return ActivityManagerNative.getDefault()
- .startNextMatchingActivity(mToken, intent);
+ .startNextMatchingActivity(mToken, intent, options);
} catch (RemoteException e) {
// Empty
}
@@ -3446,7 +3614,25 @@
throw new UnsupportedOperationException(
"startNextMatchingActivity can only be called from a top-level activity");
}
-
+
+ /**
+ * Same as calling {@link #startActivityFromChild(Activity, Intent, int, Bundle)}
+ * with no options.
+ *
+ * @param child The activity making the call.
+ * @param intent The intent to start.
+ * @param requestCode Reply request code. < 0 if reply is not requested.
+ *
+ * @throws android.content.ActivityNotFoundException
+ *
+ * @see #startActivity
+ * @see #startActivityForResult
+ */
+ public void startActivityFromChild(Activity child, Intent intent,
+ int requestCode) {
+ startActivityFromChild(child, intent, requestCode);
+ }
+
/**
* This is called when a child activity of this one calls its
* {@link #startActivity} or {@link #startActivityForResult} method.
@@ -3456,7 +3642,9 @@
*
* @param child The activity making the call.
* @param intent The intent to start.
- * @param requestCode Reply request code. < 0 if reply is not requested.
+ * @param requestCode Reply request code. < 0 if reply is not requested.
+ * @param options Additional options for how the Activity should be started.
+ * May be null if there are no options.
*
* @throws android.content.ActivityNotFoundException
*
@@ -3464,11 +3652,11 @@
* @see #startActivityForResult
*/
public void startActivityFromChild(Activity child, Intent intent,
- int requestCode) {
+ int requestCode, Bundle options) {
Instrumentation.ActivityResult ar =
mInstrumentation.execStartActivity(
this, mMainThread.getApplicationThread(), mToken, child,
- intent, requestCode);
+ intent, requestCode, options);
if (ar != null) {
mMainThread.sendActivityResult(
mToken, child.mEmbeddedID, requestCode,
@@ -3477,6 +3665,24 @@
}
/**
+ * Same as calling {@link #startActivityFromFragment(Fragment, Intent, int, Bundle)}
+ * with no options.
+ *
+ * @param fragment The fragment making the call.
+ * @param intent The intent to start.
+ * @param requestCode Reply request code. < 0 if reply is not requested.
+ *
+ * @throws android.content.ActivityNotFoundException
+ *
+ * @see Fragment#startActivity
+ * @see Fragment#startActivityForResult
+ */
+ public void startActivityFromFragment(Fragment fragment, Intent intent,
+ int requestCode) {
+ startActivityFromFragment(fragment, intent, requestCode, null);
+ }
+
+ /**
* This is called when a Fragment in this activity calls its
* {@link Fragment#startActivity} or {@link Fragment#startActivityForResult}
* method.
@@ -3487,6 +3693,8 @@
* @param fragment The fragment making the call.
* @param intent The intent to start.
* @param requestCode Reply request code. < 0 if reply is not requested.
+ * @param options Additional options for how the Activity should be started.
+ * May be null if there are no options.
*
* @throws android.content.ActivityNotFoundException
*
@@ -3494,11 +3702,11 @@
* @see Fragment#startActivityForResult
*/
public void startActivityFromFragment(Fragment fragment, Intent intent,
- int requestCode) {
+ int requestCode, Bundle options) {
Instrumentation.ActivityResult ar =
mInstrumentation.execStartActivity(
this, mMainThread.getApplicationThread(), mToken, fragment,
- intent, requestCode);
+ intent, requestCode, options);
if (ar != null) {
mMainThread.sendActivityResult(
mToken, fragment.mWho, requestCode,
@@ -3507,6 +3715,18 @@
}
/**
+ * Same as calling {@link #startIntentSenderFromChild(Activity, IntentSender,
+ * int, Intent, int, int, int, Bundle)} with no options.
+ */
+ public void startIntentSenderFromChild(Activity child, IntentSender intent,
+ int requestCode, Intent fillInIntent, int flagsMask, int flagsValues,
+ int extraFlags)
+ throws IntentSender.SendIntentException {
+ startIntentSenderFromChild(child, intent, requestCode, fillInIntent,
+ flagsMask, flagsValues, extraFlags, null);
+ }
+
+ /**
* Like {@link #startActivityFromChild(Activity, Intent, int)}, but
* taking a IntentSender; see
* {@link #startIntentSenderForResult(IntentSender, int, Intent, int, int, int)}
@@ -3514,10 +3734,10 @@
*/
public void startIntentSenderFromChild(Activity child, IntentSender intent,
int requestCode, Intent fillInIntent, int flagsMask, int flagsValues,
- int extraFlags)
+ int extraFlags, Bundle options)
throws IntentSender.SendIntentException {
startIntentSenderForResultInner(intent, requestCode, fillInIntent,
- flagsMask, flagsValues, child);
+ flagsMask, flagsValues, child, options);
}
/**
@@ -3843,7 +4063,7 @@
data.setAllowFds(false);
IIntentSender target =
ActivityManagerNative.getDefault().getIntentSender(
- IActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName,
+ ActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName,
mParent == null ? mToken : mParent.mToken,
mEmbeddedID, requestCode, new Intent[] { data }, null, flags);
return target != null ? new PendingIntent(target) : null;
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 59c803e..d056b17 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -59,6 +59,154 @@
private final Context mContext;
private final Handler mHandler;
+ /**
+ * Result for IActivityManager.startActivity: an error where the
+ * start had to be canceled.
+ * @hide
+ */
+ public static final int START_CANCELED = -6;
+
+ /**
+ * Result for IActivityManager.startActivity: an error where the
+ * thing being started is not an activity.
+ * @hide
+ */
+ public static final int START_NOT_ACTIVITY = -5;
+
+ /**
+ * Result for IActivityManager.startActivity: an error where the
+ * caller does not have permission to start the activity.
+ * @hide
+ */
+ public static final int START_PERMISSION_DENIED = -4;
+
+ /**
+ * Result for IActivityManager.startActivity: an error where the
+ * caller has requested both to forward a result and to receive
+ * a result.
+ * @hide
+ */
+ public static final int START_FORWARD_AND_REQUEST_CONFLICT = -3;
+
+ /**
+ * Result for IActivityManager.startActivity: an error where the
+ * requested class is not found.
+ * @hide
+ */
+ public static final int START_CLASS_NOT_FOUND = -2;
+
+ /**
+ * Result for IActivityManager.startActivity: an error where the
+ * given Intent could not be resolved to an activity.
+ * @hide
+ */
+ public static final int START_INTENT_NOT_RESOLVED = -1;
+
+ /**
+ * Result for IActivityManaqer.startActivity: the activity was started
+ * successfully as normal.
+ * @hide
+ */
+ public static final int START_SUCCESS = 0;
+
+ /**
+ * Result for IActivityManaqer.startActivity: the caller asked that the Intent not
+ * be executed if it is the recipient, and that is indeed the case.
+ * @hide
+ */
+ public static final int START_RETURN_INTENT_TO_CALLER = 1;
+
+ /**
+ * Result for IActivityManaqer.startActivity: activity wasn't really started, but
+ * a task was simply brought to the foreground.
+ * @hide
+ */
+ public static final int START_TASK_TO_FRONT = 2;
+
+ /**
+ * Result for IActivityManaqer.startActivity: activity wasn't really started, but
+ * the given Intent was given to the existing top activity.
+ * @hide
+ */
+ public static final int START_DELIVERED_TO_TOP = 3;
+
+ /**
+ * Result for IActivityManaqer.startActivity: request was canceled because
+ * app switches are temporarily canceled to ensure the user's last request
+ * (such as pressing home) is performed.
+ * @hide
+ */
+ public static final int START_SWITCHES_CANCELED = 4;
+
+ /**
+ * Flag for IActivityManaqer.startActivity: do special start mode where
+ * a new activity is launched only if it is needed.
+ * @hide
+ */
+ public static final int START_FLAG_ONLY_IF_NEEDED = 1<<0;
+
+ /**
+ * Flag for IActivityManaqer.startActivity: launch the app for
+ * debugging.
+ * @hide
+ */
+ public static final int START_FLAG_DEBUG = 1<<1;
+
+ /**
+ * Flag for IActivityManaqer.startActivity: launch the app for
+ * OpenGL tracing.
+ * @hide
+ */
+ public static final int START_FLAG_OPENGL_TRACES = 1<<2;
+
+ /**
+ * Flag for IActivityManaqer.startActivity: if the app is being
+ * launched for profiling, automatically stop the profiler once done.
+ * @hide
+ */
+ public static final int START_FLAG_AUTO_STOP_PROFILER = 1<<3;
+
+ /**
+ * Result for IActivityManaqer.broadcastIntent: success!
+ * @hide
+ */
+ public static final int BROADCAST_SUCCESS = 0;
+
+ /**
+ * Result for IActivityManaqer.broadcastIntent: attempt to broadcast
+ * a sticky intent without appropriate permission.
+ * @hide
+ */
+ public static final int BROADCAST_STICKY_CANT_HAVE_PERMISSION = -1;
+
+ /**
+ * Type for IActivityManaqer.getIntentSender: this PendingIntent is
+ * for a sendBroadcast operation.
+ * @hide
+ */
+ public static final int INTENT_SENDER_BROADCAST = 1;
+
+ /**
+ * Type for IActivityManaqer.getIntentSender: this PendingIntent is
+ * for a startActivity operation.
+ * @hide
+ */
+ public static final int INTENT_SENDER_ACTIVITY = 2;
+
+ /**
+ * Type for IActivityManaqer.getIntentSender: this PendingIntent is
+ * for an activity result operation.
+ * @hide
+ */
+ public static final int INTENT_SENDER_ACTIVITY_RESULT = 3;
+
+ /**
+ * Type for IActivityManaqer.getIntentSender: this PendingIntent is
+ * for a startService operation.
+ * @hide
+ */
+ public static final int INTENT_SENDER_SERVICE = 4;
+
/*package*/ ActivityManager(Context context, Handler handler) {
mContext = context;
mHandler = handler;
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index 7daaf7d..732d211 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -117,22 +117,18 @@
IApplicationThread app = ApplicationThreadNative.asInterface(b);
Intent intent = Intent.CREATOR.createFromParcel(data);
String resolvedType = data.readString();
- Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
- int grantedMode = data.readInt();
IBinder resultTo = data.readStrongBinder();
String resultWho = data.readString();
int requestCode = data.readInt();
- boolean onlyIfNeeded = data.readInt() != 0;
- boolean debug = data.readInt() != 0;
- boolean openglTrace = data.readInt() != 0;
+ int startFlags = data.readInt();
String profileFile = data.readString();
ParcelFileDescriptor profileFd = data.readInt() != 0
? data.readFileDescriptor() : null;
- boolean autoStopProfiler = data.readInt() != 0;
+ Bundle options = data.readInt() != 0
+ ? Bundle.CREATOR.createFromParcel(data) : null;
int result = startActivity(app, intent, resolvedType,
- grantedUriPermissions, grantedMode, resultTo, resultWho,
- requestCode, onlyIfNeeded, debug, openglTrace,
- profileFile, profileFd, autoStopProfiler);
+ resultTo, resultWho, requestCode, startFlags,
+ profileFile, profileFd, options);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -145,22 +141,18 @@
IApplicationThread app = ApplicationThreadNative.asInterface(b);
Intent intent = Intent.CREATOR.createFromParcel(data);
String resolvedType = data.readString();
- Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
- int grantedMode = data.readInt();
IBinder resultTo = data.readStrongBinder();
String resultWho = data.readString();
int requestCode = data.readInt();
- boolean onlyIfNeeded = data.readInt() != 0;
- boolean debug = data.readInt() != 0;
- boolean openglTrace = data.readInt() != 0;
+ int startFlags = data.readInt();
String profileFile = data.readString();
ParcelFileDescriptor profileFd = data.readInt() != 0
? data.readFileDescriptor() : null;
- boolean autoStopProfiler = data.readInt() != 0;
+ Bundle options = data.readInt() != 0
+ ? Bundle.CREATOR.createFromParcel(data) : null;
WaitResult result = startActivityAndWait(app, intent, resolvedType,
- grantedUriPermissions, grantedMode, resultTo, resultWho,
- requestCode, onlyIfNeeded, debug, openglTrace,
- profileFile, profileFd, autoStopProfiler);
+ resultTo, resultWho, requestCode, startFlags,
+ profileFile, profileFd, options);
reply.writeNoException();
result.writeToParcel(reply, 0);
return true;
@@ -173,17 +165,15 @@
IApplicationThread app = ApplicationThreadNative.asInterface(b);
Intent intent = Intent.CREATOR.createFromParcel(data);
String resolvedType = data.readString();
- Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
- int grantedMode = data.readInt();
IBinder resultTo = data.readStrongBinder();
String resultWho = data.readString();
int requestCode = data.readInt();
- boolean onlyIfNeeded = data.readInt() != 0;
- boolean debug = data.readInt() != 0;
+ int startFlags = data.readInt();
Configuration config = Configuration.CREATOR.createFromParcel(data);
+ Bundle options = data.readInt() != 0
+ ? Bundle.CREATOR.createFromParcel(data) : null;
int result = startActivityWithConfig(app, intent, resolvedType,
- grantedUriPermissions, grantedMode, resultTo, resultWho,
- requestCode, onlyIfNeeded, debug, config);
+ resultTo, resultWho, requestCode, startFlags, config, options);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -205,9 +195,11 @@
int requestCode = data.readInt();
int flagsMask = data.readInt();
int flagsValues = data.readInt();
+ Bundle options = data.readInt() != 0
+ ? Bundle.CREATOR.createFromParcel(data) : null;
int result = startActivityIntentSender(app, intent,
fillInIntent, resolvedType, resultTo, resultWho,
- requestCode, flagsMask, flagsValues);
+ requestCode, flagsMask, flagsValues, options);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -218,7 +210,9 @@
data.enforceInterface(IActivityManager.descriptor);
IBinder callingActivity = data.readStrongBinder();
Intent intent = Intent.CREATOR.createFromParcel(data);
- boolean result = startNextMatchingActivity(callingActivity, intent);
+ Bundle options = data.readInt() != 0
+ ? Bundle.CREATOR.createFromParcel(data) : null;
+ boolean result = startNextMatchingActivity(callingActivity, intent, options);
reply.writeNoException();
reply.writeInt(result ? 1 : 0);
return true;
@@ -1231,9 +1225,11 @@
IBinder resultTo = data.readStrongBinder();
String resultWho = data.readString();
int requestCode = data.readInt();
- boolean onlyIfNeeded = data.readInt() != 0;
+ int startFlags = data.readInt();
+ Bundle options = data.readInt() != 0
+ ? Bundle.CREATOR.createFromParcel(data) : null;
int result = startActivityInPackage(uid, intent, resolvedType,
- resultTo, resultWho, requestCode, onlyIfNeeded);
+ resultTo, resultWho, requestCode, startFlags, options);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -1412,7 +1408,10 @@
Intent[] intents = data.createTypedArray(Intent.CREATOR);
String[] resolvedTypes = data.createStringArray();
IBinder resultTo = data.readStrongBinder();
- int result = startActivitiesInPackage(uid, intents, resolvedTypes, resultTo);
+ Bundle options = data.readInt() != 0
+ ? Bundle.CREATOR.createFromParcel(data) : null;
+ int result = startActivitiesInPackage(uid, intents, resolvedTypes,
+ resultTo, options);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -1426,7 +1425,10 @@
Intent[] intents = data.createTypedArray(Intent.CREATOR);
String[] resolvedTypes = data.createStringArray();
IBinder resultTo = data.readStrongBinder();
- int result = startActivities(app, intents, resolvedTypes, resultTo);
+ Bundle options = data.readInt() != 0
+ ? Bundle.CREATOR.createFromParcel(data) : null;
+ int result = startActivities(app, intents, resolvedTypes, resultTo,
+ options);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -1618,25 +1620,19 @@
}
public int startActivity(IApplicationThread caller, Intent intent,
- String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
- IBinder resultTo, String resultWho,
- int requestCode, boolean onlyIfNeeded,
- boolean debug, boolean openglTrace, String profileFile, ParcelFileDescriptor profileFd,
- boolean autoStopProfiler) throws RemoteException {
+ String resolvedType, IBinder resultTo, String resultWho, int requestCode,
+ int startFlags, String profileFile,
+ ParcelFileDescriptor profileFd, Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeStrongBinder(caller != null ? caller.asBinder() : null);
intent.writeToParcel(data, 0);
data.writeString(resolvedType);
- data.writeTypedArray(grantedUriPermissions, 0);
- data.writeInt(grantedMode);
data.writeStrongBinder(resultTo);
data.writeString(resultWho);
data.writeInt(requestCode);
- data.writeInt(onlyIfNeeded ? 1 : 0);
- data.writeInt(debug ? 1 : 0);
- data.writeInt(openglTrace ? 1 : 0);
+ data.writeInt(startFlags);
data.writeString(profileFile);
if (profileFd != null) {
data.writeInt(1);
@@ -1644,7 +1640,12 @@
} else {
data.writeInt(0);
}
- data.writeInt(autoStopProfiler ? 1 : 0);
+ if (options != null) {
+ data.writeInt(1);
+ options.writeToParcel(data, 0);
+ } else {
+ data.writeInt(0);
+ }
mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();
@@ -1653,25 +1654,19 @@
return result;
}
public WaitResult startActivityAndWait(IApplicationThread caller, Intent intent,
- String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
- IBinder resultTo, String resultWho,
- int requestCode, boolean onlyIfNeeded,
- boolean debug, boolean openglTrace, String profileFile, ParcelFileDescriptor profileFd,
- boolean autoStopProfiler) throws RemoteException {
+ String resolvedType, IBinder resultTo, String resultWho,
+ int requestCode, int startFlags, String profileFile,
+ ParcelFileDescriptor profileFd, Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeStrongBinder(caller != null ? caller.asBinder() : null);
intent.writeToParcel(data, 0);
data.writeString(resolvedType);
- data.writeTypedArray(grantedUriPermissions, 0);
- data.writeInt(grantedMode);
data.writeStrongBinder(resultTo);
data.writeString(resultWho);
data.writeInt(requestCode);
- data.writeInt(onlyIfNeeded ? 1 : 0);
- data.writeInt(debug ? 1 : 0);
- data.writeInt(openglTrace ? 1 : 0);
+ data.writeInt(startFlags);
data.writeString(profileFile);
if (profileFd != null) {
data.writeInt(1);
@@ -1679,7 +1674,12 @@
} else {
data.writeInt(0);
}
- data.writeInt(autoStopProfiler ? 1 : 0);
+ if (options != null) {
+ data.writeInt(1);
+ options.writeToParcel(data, 0);
+ } else {
+ data.writeInt(0);
+ }
mRemote.transact(START_ACTIVITY_AND_WAIT_TRANSACTION, data, reply, 0);
reply.readException();
WaitResult result = WaitResult.CREATOR.createFromParcel(reply);
@@ -1688,24 +1688,26 @@
return result;
}
public int startActivityWithConfig(IApplicationThread caller, Intent intent,
- String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
- IBinder resultTo, String resultWho,
- int requestCode, boolean onlyIfNeeded,
- boolean debug, Configuration config) throws RemoteException {
+ String resolvedType, IBinder resultTo, String resultWho,
+ int requestCode, int startFlags, Configuration config,
+ Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeStrongBinder(caller != null ? caller.asBinder() : null);
intent.writeToParcel(data, 0);
data.writeString(resolvedType);
- data.writeTypedArray(grantedUriPermissions, 0);
- data.writeInt(grantedMode);
data.writeStrongBinder(resultTo);
data.writeString(resultWho);
data.writeInt(requestCode);
- data.writeInt(onlyIfNeeded ? 1 : 0);
- data.writeInt(debug ? 1 : 0);
+ data.writeInt(startFlags);
config.writeToParcel(data, 0);
+ if (options != null) {
+ data.writeInt(1);
+ options.writeToParcel(data, 0);
+ } else {
+ data.writeInt(0);
+ }
mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();
@@ -1716,7 +1718,7 @@
public int startActivityIntentSender(IApplicationThread caller,
IntentSender intent, Intent fillInIntent, String resolvedType,
IBinder resultTo, String resultWho, int requestCode,
- int flagsMask, int flagsValues) throws RemoteException {
+ int flagsMask, int flagsValues, Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
@@ -1734,6 +1736,12 @@
data.writeInt(requestCode);
data.writeInt(flagsMask);
data.writeInt(flagsValues);
+ if (options != null) {
+ data.writeInt(1);
+ options.writeToParcel(data, 0);
+ } else {
+ data.writeInt(0);
+ }
mRemote.transact(START_ACTIVITY_INTENT_SENDER_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();
@@ -1742,12 +1750,18 @@
return result;
}
public boolean startNextMatchingActivity(IBinder callingActivity,
- Intent intent) throws RemoteException {
+ Intent intent, Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeStrongBinder(callingActivity);
intent.writeToParcel(data, 0);
+ if (options != null) {
+ data.writeInt(1);
+ options.writeToParcel(data, 0);
+ } else {
+ data.writeInt(0);
+ }
mRemote.transact(START_NEXT_MATCHING_ACTIVITY_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();
@@ -3075,7 +3089,7 @@
public int startActivityInPackage(int uid,
Intent intent, String resolvedType, IBinder resultTo,
- String resultWho, int requestCode, boolean onlyIfNeeded)
+ String resultWho, int requestCode, int startFlags, Bundle options)
throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
@@ -3086,7 +3100,13 @@
data.writeStrongBinder(resultTo);
data.writeString(resultWho);
data.writeInt(requestCode);
- data.writeInt(onlyIfNeeded ? 1 : 0);
+ data.writeInt(startFlags);
+ if (options != null) {
+ data.writeInt(1);
+ options.writeToParcel(data, 0);
+ } else {
+ data.writeInt(0);
+ }
mRemote.transact(START_ACTIVITY_IN_PACKAGE_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();
@@ -3339,7 +3359,8 @@
}
public int startActivities(IApplicationThread caller,
- Intent[] intents, String[] resolvedTypes, IBinder resultTo) throws RemoteException {
+ Intent[] intents, String[] resolvedTypes, IBinder resultTo,
+ Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
@@ -3347,6 +3368,12 @@
data.writeTypedArray(intents, 0);
data.writeStringArray(resolvedTypes);
data.writeStrongBinder(resultTo);
+ if (options != null) {
+ data.writeInt(1);
+ options.writeToParcel(data, 0);
+ } else {
+ data.writeInt(0);
+ }
mRemote.transact(START_ACTIVITIES_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();
@@ -3356,7 +3383,8 @@
}
public int startActivitiesInPackage(int uid,
- Intent[] intents, String[] resolvedTypes, IBinder resultTo) throws RemoteException {
+ Intent[] intents, String[] resolvedTypes, IBinder resultTo,
+ Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
@@ -3364,6 +3392,12 @@
data.writeTypedArray(intents, 0);
data.writeStringArray(resolvedTypes);
data.writeStrongBinder(resultTo);
+ if (options != null) {
+ data.writeInt(1);
+ options.writeToParcel(data, 0);
+ } else {
+ data.writeInt(0);
+ }
mRemote.transact(START_ACTIVITIES_IN_PACKAGE_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 2610d87..2a3e213 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -1802,7 +1802,7 @@
if (aInfo == null) {
// Throw an exception.
Instrumentation.checkStartActivityResult(
- IActivityManager.START_CLASS_NOT_FOUND, intent);
+ ActivityManager.START_CLASS_NOT_FOUND, intent);
}
return aInfo;
}
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index e348b87..7043a73 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -852,6 +852,11 @@
@Override
public void startActivity(Intent intent) {
+ startActivity(intent, null);
+ }
+
+ @Override
+ public void startActivity(Intent intent, Bundle options) {
if ((intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
throw new AndroidRuntimeException(
"Calling startActivity() from outside of an Activity "
@@ -860,11 +865,16 @@
}
mMainThread.getInstrumentation().execStartActivity(
getOuterContext(), mMainThread.getApplicationThread(), null,
- (Activity)null, intent, -1);
+ (Activity)null, intent, -1, options);
}
@Override
public void startActivities(Intent[] intents) {
+ startActivities(intents, null);
+ }
+
+ @Override
+ public void startActivities(Intent[] intents, Bundle options) {
if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
throw new AndroidRuntimeException(
"Calling startActivities() from outside of an Activity "
@@ -873,13 +883,20 @@
}
mMainThread.getInstrumentation().execStartActivities(
getOuterContext(), mMainThread.getApplicationThread(), null,
- (Activity)null, intents);
+ (Activity)null, intents, options);
}
@Override
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
throws IntentSender.SendIntentException {
+ startIntentSender(intent, fillInIntent, flagsMask, flagsValues, extraFlags, null);
+ }
+
+ @Override
+ public void startIntentSender(IntentSender intent, Intent fillInIntent,
+ int flagsMask, int flagsValues, int extraFlags, Bundle options)
+ throws IntentSender.SendIntentException {
try {
String resolvedType = null;
if (fillInIntent != null) {
@@ -889,8 +906,8 @@
int result = ActivityManagerNative.getDefault()
.startActivityIntentSender(mMainThread.getApplicationThread(), intent,
fillInIntent, resolvedType, null, null,
- 0, flagsMask, flagsValues);
- if (result == IActivityManager.START_CANCELED) {
+ 0, flagsMask, flagsValues, options);
+ if (result == ActivityManager.START_CANCELED) {
throw new IntentSender.SendIntentException();
}
Instrumentation.checkStartActivityResult(result, null);
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java
index 492fcc7..dadc4e5 100644
--- a/core/java/android/app/Fragment.java
+++ b/core/java/android/app/Fragment.java
@@ -961,27 +961,55 @@
mLoaderManager = mActivity.getLoaderManager(mIndex, mLoadersStarted, true);
return mLoaderManager;
}
-
+
/**
* Call {@link Activity#startActivity(Intent)} on the fragment's
* containing Activity.
*/
public void startActivity(Intent intent) {
+ startActivity(intent, null);
+ }
+
+ /**
+ * Call {@link Activity#startActivity(Intent, Bundle)} on the fragment's
+ * containing Activity.
+ */
+ public void startActivity(Intent intent, Bundle options) {
if (mActivity == null) {
throw new IllegalStateException("Fragment " + this + " not attached to Activity");
}
- mActivity.startActivityFromFragment(this, intent, -1);
+ if (options != null) {
+ mActivity.startActivityFromFragment(this, intent, -1, options);
+ } else {
+ // Note we want to go through this call for compatibility with
+ // applications that may have overridden the method.
+ mActivity.startActivityFromFragment(this, intent, -1);
+ }
}
-
+
/**
* Call {@link Activity#startActivityForResult(Intent, int)} on the fragment's
* containing Activity.
*/
public void startActivityForResult(Intent intent, int requestCode) {
+ startActivityForResult(intent, requestCode, null);
+ }
+
+ /**
+ * Call {@link Activity#startActivityForResult(Intent, int, Bundle)} on the fragment's
+ * containing Activity.
+ */
+ public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
if (mActivity == null) {
throw new IllegalStateException("Fragment " + this + " not attached to Activity");
}
- mActivity.startActivityFromFragment(this, intent, requestCode);
+ if (options != null) {
+ mActivity.startActivityFromFragment(this, intent, requestCode, options);
+ } else {
+ // Note we want to go through this call for compatibility with
+ // applications that may have overridden the method.
+ mActivity.startActivityFromFragment(this, intent, requestCode, options);
+ }
}
/**
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index acebf58..9306bd2 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -50,57 +50,24 @@
* {@hide}
*/
public interface IActivityManager extends IInterface {
- /**
- * Returned by startActivity() if the start request was canceled because
- * app switches are temporarily canceled to ensure the user's last request
- * (such as pressing home) is performed.
- */
- public static final int START_SWITCHES_CANCELED = 4;
- /**
- * Returned by startActivity() if an activity wasn't really started, but
- * the given Intent was given to the existing top activity.
- */
- public static final int START_DELIVERED_TO_TOP = 3;
- /**
- * Returned by startActivity() if an activity wasn't really started, but
- * a task was simply brought to the foreground.
- */
- public static final int START_TASK_TO_FRONT = 2;
- /**
- * Returned by startActivity() if the caller asked that the Intent not
- * be executed if it is the recipient, and that is indeed the case.
- */
- public static final int START_RETURN_INTENT_TO_CALLER = 1;
- /**
- * Activity was started successfully as normal.
- */
- public static final int START_SUCCESS = 0;
- public static final int START_INTENT_NOT_RESOLVED = -1;
- public static final int START_CLASS_NOT_FOUND = -2;
- public static final int START_FORWARD_AND_REQUEST_CONFLICT = -3;
- public static final int START_PERMISSION_DENIED = -4;
- public static final int START_NOT_ACTIVITY = -5;
- public static final int START_CANCELED = -6;
public int startActivity(IApplicationThread caller,
- Intent intent, String resolvedType, Uri[] grantedUriPermissions,
- int grantedMode, IBinder resultTo, String resultWho, int requestCode,
- boolean onlyIfNeeded, boolean debug, boolean openglTrace, String profileFile,
- ParcelFileDescriptor profileFd, boolean autoStopProfiler) throws RemoteException;
+ Intent intent, String resolvedType, IBinder resultTo, String resultWho,
+ int requestCode, int flags, String profileFile,
+ ParcelFileDescriptor profileFd, Bundle options) throws RemoteException;
public WaitResult startActivityAndWait(IApplicationThread caller,
- Intent intent, String resolvedType, Uri[] grantedUriPermissions,
- int grantedMode, IBinder resultTo, String resultWho, int requestCode,
- boolean onlyIfNeeded, boolean debug, boolean openglTrace, String profileFile,
- ParcelFileDescriptor profileFd, boolean autoStopProfiler) throws RemoteException;
+ Intent intent, String resolvedType, IBinder resultTo, String resultWho,
+ int requestCode, int flags, String profileFile,
+ ParcelFileDescriptor profileFd, Bundle options) throws RemoteException;
public int startActivityWithConfig(IApplicationThread caller,
- Intent intent, String resolvedType, Uri[] grantedUriPermissions,
- int grantedMode, IBinder resultTo, String resultWho, int requestCode,
- boolean onlyIfNeeded, boolean debug, Configuration newConfig) throws RemoteException;
+ Intent intent, String resolvedType, IBinder resultTo, String resultWho,
+ int requestCode, int startFlags, Configuration newConfig,
+ Bundle options) throws RemoteException;
public int startActivityIntentSender(IApplicationThread caller,
IntentSender intent, Intent fillInIntent, String resolvedType,
IBinder resultTo, String resultWho, int requestCode,
- int flagsMask, int flagsValues) throws RemoteException;
+ int flagsMask, int flagsValues, Bundle options) throws RemoteException;
public boolean startNextMatchingActivity(IBinder callingActivity,
- Intent intent) throws RemoteException;
+ Intent intent, Bundle options) throws RemoteException;
public boolean finishActivity(IBinder token, int code, Intent data)
throws RemoteException;
public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException;
@@ -109,8 +76,6 @@
IIntentReceiver receiver, IntentFilter filter,
String requiredPermission) throws RemoteException;
public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException;
- public static final int BROADCAST_SUCCESS = 0;
- public static final int BROADCAST_STICKY_CANT_HAVE_PERMISSION = -1;
public int broadcastIntent(IApplicationThread caller, Intent intent,
String resolvedType, IIntentReceiver resultTo, int resultCode,
String resultData, Bundle map, String requiredPermission,
@@ -201,10 +166,6 @@
public ComponentName getActivityClassForToken(IBinder token) throws RemoteException;
public String getPackageForToken(IBinder token) throws RemoteException;
- public static final int INTENT_SENDER_BROADCAST = 1;
- public static final int INTENT_SENDER_ACTIVITY = 2;
- public static final int INTENT_SENDER_ACTIVITY_RESULT = 3;
- public static final int INTENT_SENDER_SERVICE = 4;
public IIntentSender getIntentSender(int type,
String packageName, IBinder token, String resultWho,
int requestCode, Intent[] intents, String[] resolvedTypes,
@@ -302,7 +263,7 @@
public int startActivityInPackage(int uid,
Intent intent, String resolvedType, IBinder resultTo,
- String resultWho, int requestCode, boolean onlyIfNeeded)
+ String resultWho, int requestCode, int startFlags, Bundle options)
throws RemoteException;
public void killApplicationWithUid(String pkg, int uid) throws RemoteException;
@@ -342,9 +303,11 @@
ParcelFileDescriptor fd) throws RemoteException;
public int startActivities(IApplicationThread caller,
- Intent[] intents, String[] resolvedTypes, IBinder resultTo) throws RemoteException;
+ Intent[] intents, String[] resolvedTypes, IBinder resultTo,
+ Bundle options) throws RemoteException;
public int startActivitiesInPackage(int uid,
- Intent[] intents, String[] resolvedTypes, IBinder resultTo) throws RemoteException;
+ Intent[] intents, String[] resolvedTypes, IBinder resultTo,
+ Bundle options) throws RemoteException;
public int getFrontActivityScreenCompatMode() throws RemoteException;
public void setFrontActivityScreenCompatMode(int mode) throws RemoteException;
diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java
index a34e1d3..16299de 100644
--- a/core/java/android/app/Instrumentation.java
+++ b/core/java/android/app/Instrumentation.java
@@ -1346,6 +1346,7 @@
* @param intent The actual Intent to start.
* @param requestCode Identifier for this request's result; less than zero
* if the caller is not expecting a result.
+ * @param options Addition options.
*
* @return To force the return of a particular result, return an
* ActivityResult object containing the desired data; otherwise
@@ -1361,7 +1362,7 @@
*/
public ActivityResult execStartActivity(
Context who, IBinder contextThread, IBinder token, Activity target,
- Intent intent, int requestCode) {
+ Intent intent, int requestCode, Bundle options) {
IApplicationThread whoThread = (IApplicationThread) contextThread;
if (mActivityMonitors != null) {
synchronized (mSync) {
@@ -1383,8 +1384,8 @@
int result = ActivityManagerNative.getDefault()
.startActivity(whoThread, intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
- null, 0, token, target != null ? target.mEmbeddedID : null,
- requestCode, false, false, false, null, null, false);
+ token, target != null ? target.mEmbeddedID : null,
+ requestCode, 0, null, null, options);
checkStartActivityResult(result, intent);
} catch (RemoteException e) {
}
@@ -1400,7 +1401,7 @@
* {@hide}
*/
public void execStartActivities(Context who, IBinder contextThread,
- IBinder token, Activity target, Intent[] intents) {
+ IBinder token, Activity target, Intent[] intents, Bundle options) {
IApplicationThread whoThread = (IApplicationThread) contextThread;
if (mActivityMonitors != null) {
synchronized (mSync) {
@@ -1424,7 +1425,7 @@
resolvedTypes[i] = intents[i].resolveTypeIfNeeded(who.getContentResolver());
}
int result = ActivityManagerNative.getDefault()
- .startActivities(whoThread, intents, resolvedTypes, token);
+ .startActivities(whoThread, intents, resolvedTypes, token, options);
checkStartActivityResult(result, intents[0]);
} catch (RemoteException e) {
}
@@ -1459,7 +1460,7 @@
*/
public ActivityResult execStartActivity(
Context who, IBinder contextThread, IBinder token, Fragment target,
- Intent intent, int requestCode) {
+ Intent intent, int requestCode, Bundle options) {
IApplicationThread whoThread = (IApplicationThread) contextThread;
if (mActivityMonitors != null) {
synchronized (mSync) {
@@ -1481,9 +1482,8 @@
int result = ActivityManagerNative.getDefault()
.startActivity(whoThread, intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
- null, 0, token, target != null ? target.mWho : null,
- requestCode, false, false /* debug */, false /* openglTrace */,
- null, null, false);
+ token, target != null ? target.mWho : null,
+ requestCode, 0, null, null, options);
checkStartActivityResult(result, intent);
} catch (RemoteException e) {
}
@@ -1502,13 +1502,13 @@
}
/*package*/ static void checkStartActivityResult(int res, Object intent) {
- if (res >= IActivityManager.START_SUCCESS) {
+ if (res >= ActivityManager.START_SUCCESS) {
return;
}
switch (res) {
- case IActivityManager.START_INTENT_NOT_RESOLVED:
- case IActivityManager.START_CLASS_NOT_FOUND:
+ case ActivityManager.START_INTENT_NOT_RESOLVED:
+ case ActivityManager.START_CLASS_NOT_FOUND:
if (intent instanceof Intent && ((Intent)intent).getComponent() != null)
throw new ActivityNotFoundException(
"Unable to find explicit activity class "
@@ -1516,13 +1516,13 @@
+ "; have you declared this activity in your AndroidManifest.xml?");
throw new ActivityNotFoundException(
"No Activity found to handle " + intent);
- case IActivityManager.START_PERMISSION_DENIED:
+ case ActivityManager.START_PERMISSION_DENIED:
throw new SecurityException("Not allowed to start activity "
+ intent);
- case IActivityManager.START_FORWARD_AND_REQUEST_CONFLICT:
+ case ActivityManager.START_FORWARD_AND_REQUEST_CONFLICT:
throw new AndroidRuntimeException(
"FORWARD_RESULT_FLAG used while also requesting a result");
- case IActivityManager.START_NOT_ACTIVITY:
+ case ActivityManager.START_NOT_ACTIVITY:
throw new IllegalArgumentException(
"PendingIntent is not an activity");
default:
diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java
index c95066c..57192c3 100644
--- a/core/java/android/app/PendingIntent.java
+++ b/core/java/android/app/PendingIntent.java
@@ -195,7 +195,7 @@
intent.setAllowFds(false);
IIntentSender target =
ActivityManagerNative.getDefault().getIntentSender(
- IActivityManager.INTENT_SENDER_ACTIVITY, packageName,
+ ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
null, null, requestCode, new Intent[] { intent },
resolvedType != null ? new String[] { resolvedType } : null, flags);
return target != null ? new PendingIntent(target) : null;
@@ -256,7 +256,7 @@
try {
IIntentSender target =
ActivityManagerNative.getDefault().getIntentSender(
- IActivityManager.INTENT_SENDER_ACTIVITY, packageName,
+ ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
null, null, requestCode, intents, resolvedTypes, flags);
return target != null ? new PendingIntent(target) : null;
} catch (RemoteException e) {
@@ -292,7 +292,7 @@
intent.setAllowFds(false);
IIntentSender target =
ActivityManagerNative.getDefault().getIntentSender(
- IActivityManager.INTENT_SENDER_BROADCAST, packageName,
+ ActivityManager.INTENT_SENDER_BROADCAST, packageName,
null, null, requestCode, new Intent[] { intent },
resolvedType != null ? new String[] { resolvedType } : null, flags);
return target != null ? new PendingIntent(target) : null;
@@ -330,7 +330,7 @@
intent.setAllowFds(false);
IIntentSender target =
ActivityManagerNative.getDefault().getIntentSender(
- IActivityManager.INTENT_SENDER_SERVICE, packageName,
+ ActivityManager.INTENT_SENDER_SERVICE, packageName,
null, null, requestCode, new Intent[] { intent },
resolvedType != null ? new String[] { resolvedType } : null, flags);
return target != null ? new PendingIntent(target) : null;
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 0e9e256..19a5bc0 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -818,6 +818,19 @@
public abstract void clearWallpaper() throws IOException;
/**
+ * Same as {@link #startActivity(Intent, Bundle)} with no options
+ * specified.
+ *
+ * @param intent The description of the activity to start.
+ *
+ * @throws ActivityNotFoundException
+ *
+ * @see {@link #startActivity(Intent, Bundle)}
+ * @see PackageManager#resolveActivity
+ */
+ public abstract void startActivity(Intent intent);
+
+ /**
* Launch a new activity. You will not receive any information about when
* the activity exits.
*
@@ -832,12 +845,28 @@
* if there was no Activity found to run the given Intent.
*
* @param intent The description of the activity to start.
+ * @param options Additional options for how the Activity should be started.
+ * May be null if there are no options.
*
* @throws ActivityNotFoundException
*
+ * @see {@link #startActivity(Intent)}
* @see PackageManager#resolveActivity
*/
- public abstract void startActivity(Intent intent);
+ public abstract void startActivity(Intent intent, Bundle options);
+
+ /**
+ * Same as {@link #startActivities(Intent[], Bundle)} with no options
+ * specified.
+ *
+ * @param intents An array of Intents to be started.
+ *
+ * @throws ActivityNotFoundException
+ *
+ * @see {@link #startActivities(Intent[], Bundle)}
+ * @see PackageManager#resolveActivity
+ */
+ public abstract void startActivities(Intent[] intents);
/**
* Launch multiple new activities. This is generally the same as calling
@@ -854,15 +883,38 @@
* list may be on it, some not), so you probably want to avoid such situations.
*
* @param intents An array of Intents to be started.
+ * @param options Additional options for how the Activity should be started.
+ * May be null if there are no options.
*
* @throws ActivityNotFoundException
*
+ * @see {@link #startActivities(Intent[])}
* @see PackageManager#resolveActivity
*/
- public abstract void startActivities(Intent[] intents);
+ public abstract void startActivities(Intent[] intents, Bundle options);
/**
- * Like {@link #startActivity(Intent)}, but taking a IntentSender
+ * Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)}
+ * with no options specified.
+ *
+ * @param intent The IntentSender to launch.
+ * @param fillInIntent If non-null, this will be provided as the
+ * intent parameter to {@link IntentSender#sendIntent}.
+ * @param flagsMask Intent flags in the original IntentSender that you
+ * would like to change.
+ * @param flagsValues Desired values for any bits set in
+ * <var>flagsMask</var>
+ * @param extraFlags Always set to 0.
+ *
+ * @see #startActivity(Intent)
+ * @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle)
+ */
+ public abstract void startIntentSender(IntentSender intent,
+ Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
+ throws IntentSender.SendIntentException;
+
+ /**
+ * Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender
* to start. If the IntentSender is for an activity, that activity will be started
* as if you had called the regular {@link #startActivity(Intent)}
* here; otherwise, its associated action will be executed (such as
@@ -877,10 +929,15 @@
* @param flagsValues Desired values for any bits set in
* <var>flagsMask</var>
* @param extraFlags Always set to 0.
+ * @param options Additional options for how the Activity should be started.
+ * May be null if there are no options.
+ *
+ * @see #startActivity(Intent, Bundle)
+ * @see #startIntentSender(IntentSender, Intent, int, int, int)
*/
public abstract void startIntentSender(IntentSender intent,
- Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
- throws IntentSender.SendIntentException;
+ Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
+ Bundle options) throws IntentSender.SendIntentException;
/**
* Broadcast the given intent to all interested BroadcastReceivers. This
diff --git a/core/java/android/content/ContextWrapper.java b/core/java/android/content/ContextWrapper.java
index 5ba9dcc..6b950e0 100644
--- a/core/java/android/content/ContextWrapper.java
+++ b/core/java/android/content/ContextWrapper.java
@@ -277,17 +277,35 @@
}
@Override
+ public void startActivity(Intent intent, Bundle options) {
+ mBase.startActivity(intent, options);
+ }
+
+ @Override
public void startActivities(Intent[] intents) {
mBase.startActivities(intents);
}
@Override
+ public void startActivities(Intent[] intents, Bundle options) {
+ mBase.startActivities(intents, options);
+ }
+
+ @Override
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
throws IntentSender.SendIntentException {
mBase.startIntentSender(intent, fillInIntent, flagsMask,
flagsValues, extraFlags);
}
+
+ @Override
+ public void startIntentSender(IntentSender intent,
+ Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
+ Bundle options) throws IntentSender.SendIntentException {
+ mBase.startIntentSender(intent, fillInIntent, flagsMask,
+ flagsValues, extraFlags, options);
+ }
@Override
public void sendBroadcast(Intent intent) {