Merge "Disallow starting activities without new task from non-activity context." into oc-dev am: 3ebe54b3e6

am: b8bcdf50e4

Change-Id: Ib3a056213274cd3d7b86859be43893777f4230cb
This commit is contained in:
Bryce Lee
2017-05-22 14:58:30 +00:00
committed by android-build-merger

View File

@@ -844,8 +844,9 @@ class ContextImpl extends Context {
// Calling start activity from outside an activity without FLAG_ACTIVITY_NEW_TASK is
// generally not allowed, except if the caller specifies the task id the activity should
// be launched in.
if ((intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0
&& options != null && ActivityOptions.fromBundle(options).getLaunchTaskId() == -1) {
if ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == 0
&& (options == null
|| ActivityOptions.fromBundle(options).getLaunchTaskId() == -1)) {
throw new AndroidRuntimeException(
"Calling startActivity() from outside of an Activity "
+ " context requires the FLAG_ACTIVITY_NEW_TASK flag."