隐藏图标


public static void hideAppIcon(Context ctx){
    PackageManager packageManager = ctx.getPackageManager();
    ComponentName componentName = new ComponentName(ctx, SplashActivity.class);
    int res = packageManager.getComponentEnabledSetting(componentName);
    if (res == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
            || res == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
        // 隐藏应用图标
        packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
    }
}

public static void showAppIcon(Context ctx){
    PackageManager packageManager = ctx.getPackageManager();
    ComponentName componentName = new ComponentName(ctx, SplashActivity.class);
    int res = packageManager.getComponentEnabledSetting(componentName);
    if (res == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
        // 显示应用图标
        packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
                PackageManager.DONT_KILL_APP);
    }
}













你可能感兴趣的:(隐藏图标)