List of usage examples for android.content.pm PackageManager setComponentEnabledSetting
public abstract void setComponentEnabledSetting(@NonNull ComponentName componentName, @EnabledState int newState, @EnabledFlags int flags);
From source file:Main.java
public static void disableComponent(PackageManager pm, ComponentName component) { pm.setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }
From source file:Main.java
public static void enableComponent(PackageManager pm, ComponentName component) { pm.setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); }
From source file:Main.java
/** * Enable broadcast received component./*from w w w . j a va 2 s . c o m*/ * @param c * @param component */ public static void enableReceiver(Context c, Class component) { ComponentName receiver = new ComponentName(c, component); PackageManager pm = c.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); }
From source file:Main.java
/** * Disable broadcast received component. * @param c//from w w w . j a v a 2 s . co m * @param component */ public static void disableReceiver(Context c, Class component) { ComponentName receiver = new ComponentName(c, component); PackageManager pm = c.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }
From source file:Main.java
public static void setComponentEnabled(Class<?> componentClass, boolean enabled, Context context) { ComponentName componentName = new ComponentName(context, componentClass); PackageManager packageManager = context.getPackageManager(); int state = enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; packageManager.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP); }
From source file:Main.java
public static void setComponentEnabled(Context ctx, Class<? extends Context> component, boolean enabled) { PackageManager pm = ctx.getPackageManager(); ComponentName componentName = new ComponentName(ctx, component); int state = enabled ? COMPONENT_ENABLED_STATE_ENABLED : COMPONENT_ENABLED_STATE_DISABLED; pm.setComponentEnabledSetting(componentName, state, DONT_KILL_APP); }
From source file:com.kaliturin.blacklist.utils.DefaultSMSAppHelper.java
public static void enableSMSReceiving(Context context, boolean enable) { int state = (enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED); PackageManager packageManager = context.getPackageManager(); ComponentName componentName = new ComponentName(context, SMSBroadcastReceiver.class); packageManager.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP); }
From source file:Main.java
/** * Enable/Disable Broadcast Receiver/*from w w w .ja va 2 s .co m*/ * * @param context * the context * @param brClass * the br class * @param enabled * the enabled */ public static void setStateOfReceiver(Context context, Class<?> brClass, boolean enabled) { ComponentName receiverName = new ComponentName(context, brClass.getName()); PackageManager pm = context.getPackageManager(); int newstate; if (enabled) { newstate = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; } else { newstate = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; } pm.setComponentEnabledSetting(receiverName, newstate, PackageManager.DONT_KILL_APP); }
From source file:Main.java
public static void setComponentEnabled(PackageManager packageManager, Context context, Class<?>[] classes, boolean enabled) { int length = classes.length; for (int i = 0; i < length; i++) { Class<?> clazz = classes[i]; final ComponentName c = new ComponentName(context, clazz.getName()); packageManager.setComponentEnabledSetting(c, enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }/*w ww . j ava 2 s .c om*/ }
From source file:com.google.android.apps.iosched.util.UIUtils.java
public static void enableDisableActivities(final Context context) { boolean isHoneycombTablet = isHoneycombTablet(context); PackageManager pm = context.getPackageManager(); // Enable/disable phone activities for (Class a : sPhoneActivities) { pm.setComponentEnabledSetting(new ComponentName(context, a), isHoneycombTablet ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED : PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); }//from w w w. j a va 2 s. c om // Enable/disable tablet activities for (Class a : sTabletActivities) { pm.setComponentEnabledSetting(new ComponentName(context, a), isHoneycombTablet ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } }