summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Bryce Lee <brycelee@google.com> 2017-05-22 14:30:59 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-05-22 14:31:07 +0000
commit3ebe54b3e6e3392e18c9a7816191a73903aa162b (patch)
tree21046c0662875b988b3e9a10f3356741ac6a1675
parented83139842059d60c9afe1ff3a248552d9296ed1 (diff)
parent8b49a5c0aa18f70bc59b972e888d5ad455e4d7ca (diff)
Merge "Disallow starting activities without new task from non-activity context." into oc-dev
-rw-r--r--core/java/android/app/ContextImpl.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 2de205b40970..723204f35e95 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -846,8 +846,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."