Java tutorial
//package com.java2s; //License from project: Apache License import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; public class Main { public static void toggleComponent(Context context, Class componentClass, boolean state) { ComponentName componentName = new ComponentName(context, componentClass); context.getPackageManager().setComponentEnabledSetting(componentName, state ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } }