Example usage for android.content Intent FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS

List of usage examples for android.content Intent FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS

Introduction

In this page you can find the example usage for android.content Intent FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS.

Prototype

int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS

To view the source code for android.content Intent FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS.

Click Source Link

Document

If set, the new activity is not kept in the list of recently launched activities.

Usage

From source file:com.android.launcher2.Launcher.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (isWorkspaceLocked()) {
        return false;
    }//from   w w  w.ja v  a 2 s.  co  m

    super.onCreateOptionsMenu(menu);

    Intent manageApps = new Intent(Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS);
    manageApps.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    Intent settings = new Intent(android.provider.Settings.ACTION_SETTINGS);
    settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    String helpUrl = getString(R.string.help_url);
    Intent help = new Intent(Intent.ACTION_VIEW, Uri.parse(helpUrl));
    help.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

    menu.add(MENU_GROUP_WALLPAPER, MENU_WALLPAPER_SETTINGS, 0, R.string.menu_wallpaper)
            .setIcon(android.R.drawable.ic_menu_gallery).setAlphabeticShortcut('W');
    menu.add(0, MENU_MANAGE_APPS, 0, R.string.menu_manage_apps).setIcon(android.R.drawable.ic_menu_manage)
            .setIntent(manageApps).setAlphabeticShortcut('M');
    menu.add(0, MENU_SYSTEM_SETTINGS, 0, R.string.menu_settings).setIcon(android.R.drawable.ic_menu_preferences)
            .setIntent(settings).setAlphabeticShortcut('P');
    if (!helpUrl.isEmpty()) {
        menu.add(0, MENU_HELP, 0, R.string.menu_help).setIcon(android.R.drawable.ic_menu_help).setIntent(help)
                .setAlphabeticShortcut('H');
    }
    return true;
}

From source file:com.android.leanlauncher.LauncherTransitionable.java

boolean startApplicationUninstallActivity(ComponentName componentName, int flags, UserHandleCompat user) {
    if ((flags & AppInfo.DOWNLOADED_FLAG) == 0) {
        // System applications cannot be installed. For now, show a toast explaining that.
        // We may give them the option of disabling apps this way.
        int messageId = R.string.uninstall_system_app_text;
        Toast.makeText(this, messageId, Toast.LENGTH_SHORT).show();
        return false;
    } else {// w  w  w .  j a  v  a2  s .c o  m
        String packageName = componentName.getPackageName();
        String className = componentName.getClassName();
        Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        if (user != null) {
            user.addToIntent(intent, Intent.EXTRA_USER);
        }
        startActivity(intent);
        return true;
    }
}

From source file:com.android.launcher2.Launcher.java

void startApplicationDetailsActivity(ComponentName componentName) {
    String packageName = componentName.getPackageName();
    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
            Uri.fromParts("package", packageName, null));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    startActivitySafely(null, intent, "startApplicationDetailsActivity");
}

From source file:com.android.launcher2.Launcher.java

void startApplicationUninstallActivity(ApplicationInfo appInfo) {
    if ((appInfo.flags & ApplicationInfo.DOWNLOADED_FLAG) == 0) {
        // System applications cannot be installed. For now, show a toast explaining that.
        // We may give them the option of disabling apps this way.
        int messageId = R.string.uninstall_system_app_text;
        Toast.makeText(this, messageId, Toast.LENGTH_SHORT).show();
    } else {/*from   w  ww. j a  va2  s. co  m*/
        String packageName = appInfo.componentName.getPackageName();
        String className = appInfo.componentName.getClassName();
        Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        startActivity(intent);
    }
}

From source file:com.android.soma.Launcher.java

boolean startApplicationUninstallActivity(ComponentName componentName, int flags) {
    if ((flags & AppInfo.DOWNLOADED_FLAG) == 0) {
        // System applications cannot be installed. For now, show a toast explaining that.
        // We may give them the option of disabling apps this way.
        int messageId = R.string.uninstall_system_app_text;
        Toast.makeText(this, messageId, Toast.LENGTH_SHORT).show();
        return false;
    } else {/*from ww  w .jav a2 s  .  c  om*/
        String packageName = componentName.getPackageName();
        String className = componentName.getClassName();
        Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        startActivity(intent);
        return true;
    }
}