Java Code Examples for android.content.Intent#FLAG_ACTIVITY_NEW_TASK

The following examples show how to use android.content.Intent#FLAG_ACTIVITY_NEW_TASK . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
public void startActivity(Intent intent, Bundle options) {
    warnIfCallingFromSystemProcess();

    // 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) {
        throw new AndroidRuntimeException(
                "Calling startActivity() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivity(
            getOuterContext(), mMainThread.getApplicationThread(), null,
            (Activity) null, intent, -1, options);
}
 
Example 2
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
public void startActivity(Intent intent, Bundle options) {
    warnIfCallingFromSystemProcess();

    // 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) {
        throw new AndroidRuntimeException(
                "Calling startActivity() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivity(
            getOuterContext(), mMainThread.getApplicationThread(), null,
            (Activity) null, intent, -1, options);
}
 
Example 3
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
public void startActivity(Intent intent, Bundle options) {
    warnIfCallingFromSystemProcess();

    // 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) {
        throw new AndroidRuntimeException(
                "Calling startActivity() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivity(
            getOuterContext(), mMainThread.getApplicationThread(), null,
            (Activity) null, intent, -1, options);
}
 
Example 4
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/** @hide */
@Override
public void startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) {
    if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
        throw new AndroidRuntimeException(
                "Calling startActivities() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag on first Intent."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivitiesAsUser(
            getOuterContext(), mMainThread.getApplicationThread(), null,
            (Activity) null, intents, options, userHandle.getIdentifier());
}
 
Example 5
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/** @hide */
@Override
public int startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) {
    if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
        throw new AndroidRuntimeException(
                "Calling startActivities() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag on first Intent."
                + " Is this really what you want?");
    }
    return mMainThread.getInstrumentation().execStartActivitiesAsUser(
            getOuterContext(), mMainThread.getApplicationThread(), null,
            (Activity) null, intents, options, userHandle.getIdentifier());
}
 
Example 6
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void startActivities(Intent[] intents, Bundle options) {
    warnIfCallingFromSystemProcess();
    if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
        throw new AndroidRuntimeException(
                "Calling startActivities() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag on first Intent."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivities(
            getOuterContext(), mMainThread.getApplicationThread(), null,
            (Activity) null, intents, options);
}
 
Example 7
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@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 "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivity(
        getOuterContext(), mMainThread.getApplicationThread(), null,
        (Activity)null, intent, -1, options);
}
 
Example 8
Source File: ContextImpl.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void startActivities(Intent[] intents, Bundle options) {
    warnIfCallingFromSystemProcess();
    if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
        throw new AndroidRuntimeException(
                "Calling startActivities() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag on first Intent."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivities(
            getOuterContext(), mMainThread.getApplicationThread(), null,
            (Activity) null, intents, options);
}
 
Example 9
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void startActivities(Intent[] intents, Bundle options) {
    warnIfCallingFromSystemProcess();
    if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
        throw new AndroidRuntimeException(
                "Calling startActivities() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag on first Intent."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivities(
            getOuterContext(), mMainThread.getApplicationThread(), null,
            (Activity) null, intents, options);
}
 
Example 10
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/** @hide */
@Override
public void startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) {
    if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
        throw new AndroidRuntimeException(
                "Calling startActivities() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag on first Intent."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivitiesAsUser(
        getOuterContext(), mMainThread.getApplicationThread(), null,
        (Activity)null, intents, options, userHandle.getIdentifier());
}
 
Example 11
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void startActivity(Intent intent, Bundle options) {
    warnIfCallingFromSystemProcess();
    if ((intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
        throw new AndroidRuntimeException(
                "Calling startActivity() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivity(
        getOuterContext(), mMainThread.getApplicationThread(), null,
        (Activity)null, intent, -1, options);
}
 
Example 12
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void startActivities(Intent[] intents, Bundle options) {
    warnIfCallingFromSystemProcess();
    if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
        throw new AndroidRuntimeException(
                "Calling startActivities() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag on first Intent."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivities(
            getOuterContext(), mMainThread.getApplicationThread(), null,
            (Activity) null, intents, options);
}
 
Example 13
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/** @hide */
@Override
public void startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) {
    if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
        throw new AndroidRuntimeException(
                "Calling startActivities() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag on first Intent."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivitiesAsUser(
        getOuterContext(), mMainThread.getApplicationThread(), null,
        (Activity)null, intents, options, userHandle.getIdentifier());
}
 
Example 14
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void startActivity(Intent intent, Bundle options) {
    warnIfCallingFromSystemProcess();
    if ((intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
        throw new AndroidRuntimeException(
                "Calling startActivity() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivity(
            getOuterContext(), mMainThread.getApplicationThread(), null,
            (Activity) null, intent, -1, options);
}
 
Example 15
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/** @hide */
@Override
public void startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) {
    if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
        throw new AndroidRuntimeException(
                "Calling startActivities() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag on first Intent."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivitiesAsUser(
        getOuterContext(), mMainThread.getApplicationThread(), null,
        (Activity)null, intents, options, userHandle.getIdentifier());
}
 
Example 16
Source File: ChromeLauncherActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Records metrics gleaned from the Intent.
 */
private void recordIntentMetrics() {
    Intent intent = getIntent();
    IntentHandler.ExternalAppId source =
            IntentHandler.determineExternalIntentSource(getPackageName(), intent);
    if (intent.getPackage() == null && source != IntentHandler.ExternalAppId.CHROME) {
        int flagsOfInterest = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
        int maskedFlags = intent.getFlags() & flagsOfInterest;
        sIntentFlagsHistogram.record(maskedFlags);
    }
    MediaNotificationUma.recordClickSource(intent);
}
 
Example 17
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void startActivities(Intent[] intents, Bundle options) {
    warnIfCallingFromSystemProcess();
    if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
        throw new AndroidRuntimeException(
                "Calling startActivities() from outside of an Activity "
                + " context requires the FLAG_ACTIVITY_NEW_TASK flag on first Intent."
                + " Is this really what you want?");
    }
    mMainThread.getInstrumentation().execStartActivities(
        getOuterContext(), mMainThread.getApplicationThread(), null,
        (Activity)null, intents, options);
}
 
Example 18
Source File: ChromeLauncherActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Records metrics gleaned from the Intent.
 */
private void recordIntentMetrics() {
    Intent intent = getIntent();
    IntentHandler.ExternalAppId source =
            IntentHandler.determineExternalIntentSource(getPackageName(), intent);
    if (intent.getPackage() == null && source != IntentHandler.ExternalAppId.CHROME) {
        int flagsOfInterest = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
        int maskedFlags = intent.getFlags() & flagsOfInterest;
        sIntentFlagsHistogram.record(maskedFlags);
    }
    MediaNotificationUma.recordClickSource(intent);
}
 
Example 19
Source File: CustomTabsIntent.java    From custom-tabs-client with Apache License 2.0 2 votes vote down vote up
/**
 * Whether a browser receiving the given intent should always use browser UI and avoid using any
 * custom tabs UI.
 *
 * @param intent The intent to check for the required flags and extras.
 * @return Whether the browser UI should be used exclusively.
 */
public static boolean shouldAlwaysUseBrowserUI(Intent intent) {
    return intent.getBooleanExtra(EXTRA_USER_OPT_OUT_FROM_CUSTOM_TABS, false)
            && (intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0;
}
 
Example 20
Source File: CustomTabsIntent.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Whether a browser receiving the given intent should always use browser UI and avoid using any
 * custom tabs UI.
 *
 * @param intent The intent to check for the required flags and extras.
 * @return Whether the browser UI should be used exclusively.
 */
public static boolean shouldAlwaysUseBrowserUI(Intent intent) {
    return intent.getBooleanExtra(EXTRA_USER_OPT_OUT_FROM_CUSTOM_TABS, false)
            && (intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0;
}