当前位置: 首页>>代码示例>>Java>>正文


Java Intent.FLAG_ACTIVITY_NEW_TASK属性代码示例

本文整理汇总了Java中android.content.Intent.FLAG_ACTIVITY_NEW_TASK属性的典型用法代码示例。如果您正苦于以下问题:Java Intent.FLAG_ACTIVITY_NEW_TASK属性的具体用法?Java Intent.FLAG_ACTIVITY_NEW_TASK怎么用?Java Intent.FLAG_ACTIVITY_NEW_TASK使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.content.Intent的用法示例。


在下文中一共展示了Intent.FLAG_ACTIVITY_NEW_TASK属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onStop

@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();
        }
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:19,代码来源:ResolverActivity.java

示例2: createCustomTabActivityIntent

/**
 * 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;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:37,代码来源:ChromeLauncherActivity.java

示例3: recordIntentMetrics

/**
 * 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);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:14,代码来源:ChromeLauncherActivity.java

示例4: getStartIntentFlags

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;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:6,代码来源:RCrashHandler.java

示例5:

@TargetClass(ModuleAActivity.class)
@RequestCode(100)
@Flags(Intent.FLAG_ACTIVITY_NEW_TASK)
void goToModuleAActivity(@Key(NAME) String name, @Key(ID)int id);
 
开发者ID:seasonfif,项目名称:SwiftModule,代码行数:4,代码来源:ActivityServices.java

示例6: launchFirstRunExperience

/**
 * 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;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:76,代码来源:ChromeLauncherActivity.java

示例7: shouldAlwaysUseBrowserUI

/**
 * 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;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:11,代码来源:CustomTabsIntent.java


注:本文中的android.content.Intent.FLAG_ACTIVITY_NEW_TASK属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。