List of usage examples for android.content.pm PackageManager COMPONENT_ENABLED_STATE_ENABLED
int COMPONENT_ENABLED_STATE_ENABLED
To view the source code for android.content.pm PackageManager COMPONENT_ENABLED_STATE_ENABLED.
Click Source Link
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
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 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); }
From source file:Main.java
public static void setHideApplication(Context c, boolean hide) { ComponentName cn = new ComponentName(c.getApplicationContext(), ALIAS_CLASSNAME); int setting = hide ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED : PackageManager.COMPONENT_ENABLED_STATE_ENABLED; int current = c.getPackageManager().getComponentEnabledSetting(cn); if (current != setting) { c.getPackageManager().setComponentEnabledSetting(cn, setting, PackageManager.DONT_KILL_APP); }/*from ww w .j a v a 2s.c o m*/ }
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); }/*from w ww . j av a2 s. c o m*/ }
From source file:Main.java
/** * Enable/Disable Broadcast Receiver/*from ww w . j a va2 s. c om*/ * * @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 toggleAppIcon(Context context, boolean newState) { ComponentName componentName = new ComponentName("com.noshufou.android.su", "com.noshufou.android.su.Su"); context.getPackageManager().setComponentEnabledSetting(componentName, newState ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }
From source file:Main.java
/** * Enable broadcast received component./*w w w. jav a 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: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:org.proninyaroslav.libretorrent.settings.SettingsManager.java
public static void initPreferences(Context context) { SettingsManager pref = new SettingsManager(context); String keyAutostart = context.getString(R.string.pref_key_autostart); int flag = (pref.getBoolean(keyAutostart, false) ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED); ComponentName bootReceiver = new ComponentName(context, BootReceiver.class); context.getPackageManager().setComponentEnabledSetting(bootReceiver, flag, PackageManager.DONT_KILL_APP); String keySaveTorrentIn = context.getString(R.string.pref_key_save_torrents_in); if (pref.getString(keySaveTorrentIn, null) == null) { pref.put(keySaveTorrentIn, FileIOUtils.getDefaultDownloadPath()); }//from w ww.j a va2s.c om String keyFileManagerLastDir = context.getString(R.string.pref_key_filemanager_last_dir); if (pref.getString(keyFileManagerLastDir, null) == null) { pref.put(keyFileManagerLastDir, FileIOUtils.getDefaultDownloadPath()); } String keyMoveAfterDownloadIn = context.getString(R.string.pref_key_move_after_download_in); if (pref.getString(keyMoveAfterDownloadIn, null) == null) { pref.put(keyMoveAfterDownloadIn, FileIOUtils.getDefaultDownloadPath()); } String keyMaxDownloadSpeedLimit = context.getString(R.string.pref_key_max_download_speed); if (pref.getInt(keyMaxDownloadSpeedLimit, -1) == -1) { pref.put(keyMaxDownloadSpeedLimit, 0); } String keyMaxUploadSpeedLimit = context.getString(R.string.pref_key_max_upload_speed); if (pref.getInt(keyMaxUploadSpeedLimit, -1) == -1) { pref.put(keyMaxUploadSpeedLimit, 0); } String keyMaxConnections = context.getString(R.string.pref_key_max_connections); if (pref.getInt(keyMaxConnections, -1) == -1) { pref.put(keyMaxConnections, TorrentEngine.DEFAULT_CONNECTIONS_LIMIT); } String keyMaxActiveUploads = context.getString(R.string.pref_key_max_active_uploads); if (pref.getInt(keyMaxActiveUploads, -1) == -1) { pref.put(keyMaxActiveUploads, TorrentEngine.DEFAULT_ACTIVE_SEEDS); } String keyMaxActiveDownloads = context.getString(R.string.pref_key_max_active_downloads); if (pref.getInt(keyMaxActiveDownloads, -1) == -1) { pref.put(keyMaxActiveDownloads, TorrentEngine.DEFAULT_ACTIVE_DOWNLOADS); } String keyMaxActiveTorrents = context.getString(R.string.pref_key_max_active_torrents); if (pref.getInt(keyMaxActiveTorrents, -1) == -1) { pref.put(keyMaxActiveTorrents, TorrentEngine.DEFAULT_ACTIVE_LIMIT); } String keyNotifySound = context.getString(R.string.pref_key_notify_sound); if (pref.getString(keyMaxActiveTorrents, null) == null) { pref.put(keyNotifySound, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION).toString()); } String keyLedIndicatorColor = context.getString(R.string.pref_key_led_indicator_color_notify); if (pref.getInt(keyLedIndicatorColor, -1) == -1) { pref.put(keyLedIndicatorColor, ContextCompat.getColor(context, R.color.primary)); } String keyProxyType = context.getString(R.string.pref_key_proxy_type); if (pref.getInt(keyProxyType, -1) == -1) { pref.put(keyProxyType, Integer.parseInt(context.getString(R.string.pref_proxy_type_none_value))); } String keyProxyPort = context.getString(R.string.pref_key_proxy_port); if (pref.getInt(keyProxyPort, -1) == -1) { pref.put(keyProxyPort, TorrentEngine.DEFAULT_PROXY_PORT); } String keyEncryptMode = context.getString(R.string.pref_key_enc_mode); if (pref.getInt(keyEncryptMode, -1) == -1) { pref.put(keyEncryptMode, Integer.parseInt(context.getString(R.string.pref_enc_mode_prefer_value))); } }