Intent FLAGS对RecentApps的影响

应用打开的时候,长按home键的时候,正常情况下会出现RecentAPP界面,并且当前窗口的截图也会有Animation的生成,在替换新的launcher以后,发现第一次的时候可以,在recentAPP中把这个应用移除,再打开应用,就不会在recentAPP中出现截图了,发现这和Launcher中applicationInfo里面设置的Intent的Flag相关

默认情况下设置:

    /**
     * Must not hold the Context.
     */
    public ApplicationInfo(PackageManager pm, ResolveInfo info, IconCache iconCache,
            HashMap<Object, CharSequence> labelCache) {
        final String packageName = info.activityInfo.applicationInfo.packageName;

        this.componentName = new ComponentName(packageName, info.activityInfo.name);
        this.container = ItemInfo.NO_ID;
        this.setActivity(componentName,
                Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);

        try {
            int appFlags = pm.getApplicationInfo(packageName, 0).flags;
            if ((appFlags & android.content.pm.ApplicationInfo.FLAG_SYSTEM) == 0) {
                flags |= DOWNLOADED_FLAG;

                if ((appFlags & android.content.pm.ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
                    flags |= UPDATED_SYSTEM_APP_FLAG;
                }
            }
            firstInstallTime = pm.getPackageInfo(packageName, 0).firstInstallTime;
        } catch (NameNotFoundException e) {
            Log.d(TAG, "PackageManager.getApplicationInfo failed for " + packageName);
        }

        iconCache.getTitleAndIcon(this, info, labelCache);
    }

如果将上面的

this.setActivity(componentName,
                Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);修改成Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY

就会出问题了,自己写的launcher一定要注意

你可能感兴趣的:(Intent FLAGS对RecentApps的影响)