Java Code Examples for android.content.Intent.FLAG_ACTIVITY_NEW_TASK

The following are Jave code examples for showing how to use FLAG_ACTIVITY_NEW_TASK of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: VirtualHook   File: ResolverActivity.java   View Source Code Vote up 7 votes
@Override
protected void onStop() {
    super.onStop();
    if (mRegistered) {
        mRegistered = false;
    }
    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
        // This resolver is in the unusual situation where it has been
        // launched at the top of a new task.  We don't let it be added
        // to the recent tasks shown to the user, and we need to make sure
        // that each time we are launched we get the correct launching
        // uid (not re-using the same resolver from an old launching uid),
        // so we will now finish ourself since being no longer visible,
        // the user probably can't get back to us.
        if (!isChangingConfigurations()) {
            finish();
        }
    }
}
 
Example 2
Project: TPlayer   File: ResolverActivity.java   View Source Code Vote up 7 votes
@Override
protected void onStop() {
    super.onStop();
    if (mRegistered) {
        mRegistered = false;
    }
    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
        // This resolver is in the unusual situation where it has been
        // launched at the top of a new task.  We don't let it be added
        // to the recent tasks shown to the user, and we need to make sure
        // that each time we are launched we get the correct launching
        // uid (not re-using the same resolver from an old launching uid),
        // so we will now finish ourself since being no longer visible,
        // the user probably can't get back to us.
        if (!isChangingConfigurations()) {
            finish();
        }
    }
}
 
Example 3
Project: container   File: ResolverActivity.java   View Source Code Vote up 7 votes
@Override
protected void onStop() {
    super.onStop();
    if (mRegistered) {
        mRegistered = false;
    }
    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
        // This resolver is in the unusual situation where it has been
        // launched at the top of a new task.  We don't let it be added
        // to the recent tasks shown to the user, and we need to make sure
        // that each time we are launched we get the correct launching
        // uid (not re-using the same resolver from an old launching uid),
        // so we will now finish ourself since being no longer visible,
        // the user probably can't get back to us.
        if (!isChangingConfigurations()) {
            finish();
        }
    }
}
 
Example 4
Project: chromium-for-android-56-debug-video   File: ChromeLauncherActivity.java   View Source Code Vote up 6 votes
/**
 * Creates an Intent that can be used to launch a {@link CustomTabActivity}.
 */
public static Intent createCustomTabActivityIntent(
        Context context, Intent intent, boolean addHerbExtras) {
    // Use the copy constructor to carry over the myriad of extras.
    Uri uri = Uri.parse(IntentHandler.getUrlFromIntent(intent));

    Intent newIntent = new Intent(intent);
    newIntent.setAction(Intent.ACTION_VIEW);
    newIntent.setClassName(context, CustomTabActivity.class.getName());
    newIntent.setData(uri);

    // If a CCT intent triggers First Run, then NEW_TASK will be automatically applied.  As
    // part of that, it will inherit the EXCLUDE_FROM_RECENTS bit from ChromeLauncherActivity,
    // so explicitly remove it to ensure the CCT does not get lost in recents.
    if ((newIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0
            || (newIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) != 0) {
        newIntent.setFlags(
                newIntent.getFlags() & ~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    }

    if (addHerbExtras) {
        // TODO(tedchoc|mariakhomenko): Specifically not marking the intent is from Chrome via
        //                              IntentHandler.addTrustedIntentExtras as it breaks the
        //                              redirect logic for triggering instant apps.  See if
        //                              this is better addressed in TabRedirectHandler long
        //                              term.
        newIntent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_OPENED_BY_CHROME, true);
    } else {
        IntentUtils.safeRemoveExtra(
                intent, CustomTabIntentDataProvider.EXTRA_IS_OPENED_BY_CHROME);
    }
    if (addHerbExtras) updateHerbIntent(context, newIntent);

    return newIntent;
}
 
Example 5
Project: chromium-for-android-56-debug-video   File: ChromeLauncherActivity.java   View Source Code Vote up 6 votes
/**
 * 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 6
Project: RLibrary   File: RCrashHandler.java   View Source Code Vote up 6 votes
private static int getStartIntentFlags() {
    return Intent.FLAG_ACTIVITY_NO_ANIMATION |
            Intent.FLAG_ACTIVITY_NEW_TASK |
            Intent.FLAG_ACTIVITY_CLEAR_TASK |
            Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED;
}
 
Example 7
Project: SwiftModule   File: ActivityServices.java   View Source Code Vote up 5 votes
@TargetClass(ModuleAActivity.class)
@RequestCode(100)
@Flags(Intent.FLAG_ACTIVITY_NEW_TASK)
void goToModuleAActivity(@Key(NAME) String name, @Key(ID)int id);
 
Example 8
Project: SwiftModule   File: ActivityServices.java   View Source Code Vote up 5 votes
@TargetClass(ModuleAActivity.class)
@RequestCode(100)
@Flags(Intent.FLAG_ACTIVITY_NEW_TASK)
Intent goToModuleOther(@Key(NAME) String name, @Key(ID)int id);
 
Example 9
Project: SwiftModule   File: ActivityServices.java   View Source Code Vote up 5 votes
@Scheme("modulea://activity")
@RequestCode(100)
@Flags(Intent.FLAG_ACTIVITY_NEW_TASK)
void goToModuleOtherByScheme(@Key(NAME) String name, @Key(ID)int id);
 
Example 10
Project: chromium-for-android-56-debug-video   File: ChromeLauncherActivity.java   View Source Code Vote up 5 votes
/**
 * Tries to launch the First Run Experience.  If ChromeLauncherActivity is running with the
 * wrong Intent flags, we instead relaunch ChromeLauncherActivity to make sure it runs in its
 * own task, which then triggers First Run.
 * @return Whether or not the First Run Experience needed to be shown.
 * @param forTabbedMode Whether the First Run Experience is launched for tabbed mode.
 */
private boolean launchFirstRunExperience(boolean forTabbedMode) {
    // Tries to launch the Generic First Run Experience for intent from GSA.
    boolean showLightweightFre =
            IntentHandler.determineExternalIntentSource(this.getPackageName(), getIntent())
            != ExternalAppId.GSA;
    Intent freIntent = FirstRunFlowSequencer.checkIfFirstRunIsNecessary(
            this, getIntent(), showLightweightFre);
    if (freIntent == null) return false;

    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
        if (CommandLine.getInstance().hasSwitch(
                    ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE)) {
            boolean isTabbedModeActive = false;
            boolean isLightweightFreActive = false;
            boolean isGenericFreActive = false;
            List<WeakReference<Activity>> activities = ApplicationStatus.getRunningActivities();
            for (WeakReference<Activity> weakActivity : activities) {
                Activity activity = weakActivity.get();
                if (activity == null) {
                    continue;
                }

                if (activity instanceof ChromeTabbedActivity) {
                    isTabbedModeActive = true;
                    continue;
                }

                if (activity instanceof LightweightFirstRunActivity) {
                    isLightweightFreActive = true;
                    // A Generic or a new Lightweight First Run Experience will be launched
                    // below, so finish the old Lightweight First Run Experience.
                    activity.setResult(Activity.RESULT_CANCELED);
                    activity.finish();
                    continue;
                }

                if (activity instanceof FirstRunActivity) {
                    isGenericFreActive = true;
                    continue;
                }
            }

            if (forTabbedMode) {
                if (isTabbedModeActive || isLightweightFreActive || !showLightweightFre) {
                    // Lets ChromeTabbedActivity checks and launches the Generic First Run
                    // Experience.
                    launchTabbedMode(false);
                    finish();
                    return true;
                }
            } else if (isGenericFreActive) {
                // Launch the Generic First Run Experience if it is active previously.
                freIntent = FirstRunFlowSequencer.createGenericFirstRunIntent(
                        this, TextUtils.equals(getIntent().getAction(), Intent.ACTION_MAIN));
            }
        }
        // Add a PendingIntent so that the intent used to launch Chrome will be resent when
        // first run is completed or canceled.
        FirstRunFlowSequencer.addPendingIntent(this, freIntent, getIntent());
        freIntent.putExtra(FirstRunActivity.EXTRA_FINISH_ON_TOUCH_OUTSIDE, !forTabbedMode);
        startActivity(freIntent);
    } else {
        Intent newIntent = new Intent(getIntent());
        newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(newIntent);
    }
    finish();
    return true;
}
 
Example 11
Project: chromium-for-android-56-debug-video   File: CustomTabsIntent.java   View Source Code Vote up 3 votes
/**
 * 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;
}