Java Code Examples for android.content.pm.PackageManager#COMPONENT_ENABLED_STATE_DISABLED
The following examples show how to use
android.content.pm.PackageManager#COMPONENT_ENABLED_STATE_DISABLED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SipService.java From CSipSimple with GNU General Public License v3.0 | 6 votes |
private void applyComponentEnablingState(boolean active) { int enableState = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; if(active && prefsWrapper.getPreferenceBooleanValue(SipConfigManager.INTEGRATE_TEL_PRIVILEGED) ) { // Check whether we should register for stock tel: intents // Useful for devices without gsm enableState = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; } PackageManager pm = getPackageManager(); ComponentName cmp = new ComponentName(this, "com.csipsimple.ui.PrivilegedOutgoingCallBroadcaster"); try { if (pm.getComponentEnabledSetting(cmp) != enableState) { pm.setComponentEnabledSetting(cmp, enableState, PackageManager.DONT_KILL_APP); } } catch (IllegalArgumentException e) { Log.d(THIS_FILE, "Current manifest has no PrivilegedOutgoingCallBroadcaster -- you can ignore this if voluntary", e); } }
Example 2
Source File: DebugPreferences.java From WiFiKeyView with Apache License 2.0 | 6 votes |
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals("hide_launcher_icon")) { int newState = (sharedPreferences.getBoolean(key, false)) ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED : PackageManager.COMPONENT_ENABLED_STATE_ENABLED; PackageManager packageManager = getActivity().getPackageManager(); ComponentName componentName = new ComponentName(getActivity(), "com.whd.wifikeyview.preferences.SettingsActivity-Alias"); int oldState = packageManager.getComponentEnabledSetting(componentName); if (newState != oldState) { packageManager.setComponentEnabledSetting(componentName, newState, PackageManager.DONT_KILL_APP); } } }
Example 3
Source File: Preferences.java From MifareClassicTool with GNU General Public License v3.0 | 6 votes |
/** * Detect the current "Autostart if card is detected" state and set * the checkbox accordingly. */ private void detectAutostartIfCardDetectedState() { int enabledSetting = mPackageManager.getComponentEnabledSetting( mComponentName); switch (enabledSetting) { case PackageManager.COMPONENT_ENABLED_STATE_ENABLED: case PackageManager.COMPONENT_ENABLED_STATE_DEFAULT: mPrefAutostartIfCardDetected.setChecked(true); break; case PackageManager.COMPONENT_ENABLED_STATE_DISABLED: mPrefAutostartIfCardDetected.setChecked(false); break; default: break; } }
Example 4
Source File: AppDumperPlugin.java From droidconat-2016 with Apache License 2.0 | 6 votes |
private void displayBootReceiverState(PrintStream writer) { ComponentName componentName = new ComponentName(context, BootReceiver.class); PackageManager pm = context.getPackageManager(); writer.print("Boot receiver state: "); int state = pm.getComponentEnabledSetting(componentName); switch (state) { case PackageManager.COMPONENT_ENABLED_STATE_DEFAULT: writer.println("default"); break; case PackageManager.COMPONENT_ENABLED_STATE_ENABLED: writer.println("enabled"); break; case PackageManager.COMPONENT_ENABLED_STATE_DISABLED: writer.println("disabled"); break; case PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER: writer.println("disabled by user"); break; default: writer.println(state); break; } }
Example 5
Source File: WifiBroadcastReceiver.java From WiFiAfterConnect with Apache License 2.0 | 5 votes |
public static void setEnabled (Context context, boolean enable) { if (context == null) return; PackageManager pm = context.getPackageManager(); if (pm == null) return; ComponentName component = new ComponentName (context, WifiBroadcastReceiver.class); int status = pm.getComponentEnabledSetting(component); int statusNew = enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; if (status != statusNew) pm.setComponentEnabledSetting(component, statusNew, PackageManager.DONT_KILL_APP); }
Example 6
Source File: PropUtil.java From LocationReportEnabler with GNU General Public License v3.0 | 5 votes |
public static void hideOrShowLauncher(Context context, boolean isHide) { PackageManager p = context.getPackageManager(); ComponentName componentName = new ComponentName(context, SettingActivity.class); if (isHide) { if (p.getComponentEnabledSetting(componentName) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED) { p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); Log.d("PropUtil", "Hide the icon."); } } else { if (p.getComponentEnabledSetting(componentName) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); Log.d("PropUtil", "Show the icon."); } } }
Example 7
Source File: SettingsFragment.java From HideMockLocation with MIT License | 5 votes |
private void changeIconView(boolean showIcon) { PackageManager packageManager = getActivity().getPackageManager(); int state = showIcon ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; String alias_package = Common.PACKAGE_NAME + ".MainAlias"; ComponentName alias = new ComponentName(getActivity(), alias_package); packageManager.setComponentEnabledSetting(alias, state, PackageManager.DONT_KILL_APP); }
Example 8
Source File: MainActivity.java From XposedManyMoney with GNU General Public License v2.0 | 5 votes |
public void hideLauncherIcon(boolean isHide) { PackageManager packageManager = this.getPackageManager(); int hide = isHide ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED : PackageManager.COMPONENT_ENABLED_STATE_ENABLED; packageManager.setComponentEnabledSetting(getAliasComponentName(), hide, PackageManager.DONT_KILL_APP); }
Example 9
Source File: PackageUtils.java From Android-Next with Apache License 2.0 | 5 votes |
public static void setComponentState(Context context, Class<?> clazz, boolean enable) { ComponentName componentName = new ComponentName(context, clazz); PackageManager pm = context.getPackageManager(); final int oldState = pm.getComponentEnabledSetting(componentName); final int newState = enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; if (newState != oldState) { final int flags = PackageManager.DONT_KILL_APP; pm.setComponentEnabledSetting(componentName, newState, flags); } }
Example 10
Source File: BroadcastReceiverUtils.java From android-utils with Apache License 2.0 | 5 votes |
/** * Enable/Disable Broadcast Receiver * * @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); }
Example 11
Source File: LeanplumManifestHelper.java From Leanplum-Android-SDK with Apache License 2.0 | 5 votes |
/** * Checks if component for provided class enabled before. * * @param context Current Context. * @param packageManager Current PackageManager. * @param clazz Class for check. * @return True if component was enabled before. */ public static boolean wasComponentEnabled(Context context, PackageManager packageManager, Class clazz) { if (clazz == null || context == null || packageManager == null) { return false; } int componentStatus = packageManager.getComponentEnabledSetting(new ComponentName(context, clazz)); if (PackageManager.COMPONENT_ENABLED_STATE_DEFAULT == componentStatus || PackageManager.COMPONENT_ENABLED_STATE_DISABLED == componentStatus) { return false; } return true; }
Example 12
Source File: MainActivity.java From Shaarlier with GNU General Public License v3.0 | 5 votes |
private void setHandleHttpScheme(boolean handleHttpScheme) { if(handleHttpScheme == isHandlingHttpScheme()) return; int flag = (handleHttpScheme ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED); getPackageManager().setComponentEnabledSetting( getHttpSchemeHandlingComponent(), flag, PackageManager.DONT_KILL_APP); }
Example 13
Source File: PackageManagerShellCommand.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private static String enabledSettingToString(int state) { switch (state) { case PackageManager.COMPONENT_ENABLED_STATE_DEFAULT: return "default"; case PackageManager.COMPONENT_ENABLED_STATE_ENABLED: return "enabled"; case PackageManager.COMPONENT_ENABLED_STATE_DISABLED: return "disabled"; case PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER: return "disabled-user"; case PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED: return "disabled-until-used"; } return "unknown"; }
Example 14
Source File: UpdaterUtils.java From AndroidUpdater with Apache License 2.0 | 5 votes |
/** * 系统的下载组件是否可用 * * @return boolean */ public static boolean checkDownloadState(Context context) { try { int state = context.getPackageManager().getApplicationEnabledSetting("com.android.providers.downloads"); if (state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED || state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER || state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED) { return false; } } catch (Exception e) { e.printStackTrace(); return false; } return true; }
Example 15
Source File: DownloadManagerResolver.java From FaceSlim with GNU General Public License v2.0 | 5 votes |
/** * Resolve whether the DownloadManager is enable in current devices. * * @param context Context of application * @return true if DownloadManager is enable, false otherwise. */ private static boolean resolveEnable(Context context) { int state = context.getPackageManager() .getApplicationEnabledSetting(DOWNLOAD_MANAGER_PACKAGE_NAME); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) { return !(state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED || state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER || state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED); } else { return !(state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED || state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER); } }
Example 16
Source File: DownloadManagerResolver.java From hipda with GNU General Public License v2.0 | 5 votes |
/** * Resolve whether the DownloadManager is enable in current devices. * * @param context * @return true if DownloadManager is enable,false otherwise. */ private static boolean resolveEnable(Context context) { int state = context.getPackageManager() .getApplicationEnabledSetting(DOWNLOAD_MANAGER_PACKAGE_NAME); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) { return !(state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED || state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER || state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED); } else { return !(state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED || state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER); } }
Example 17
Source File: ScreenshotPreferences.java From EnhancedScreenshotNotification with GNU General Public License v3.0 | 4 votes |
public boolean isHideLauncherIcon() { return mPackageManager.getComponentEnabledSetting(LAUNCH_COMPONENT_NAME) == PackageManager.COMPONENT_ENABLED_STATE_DISABLED; }
Example 18
Source File: MainActivity.java From XposedWechatHelper with GNU General Public License v2.0 | 4 votes |
public void hideLauncherIcon(boolean isHide) { PackageManager packageManager = this.getPackageManager(); int hide = isHide ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED : PackageManager.COMPONENT_ENABLED_STATE_ENABLED; packageManager.setComponentEnabledSetting(getAliasComponentName(), hide, PackageManager.DONT_KILL_APP); }
Example 19
Source File: MainActivity.java From XposedRimetHelper with GNU General Public License v2.0 | 4 votes |
public void hideLauncherIcon(boolean isHide) { PackageManager packageManager = this.getPackageManager(); int hide = isHide ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED : PackageManager.COMPONENT_ENABLED_STATE_ENABLED; packageManager.setComponentEnabledSetting(getAliasComponentName(), hide, PackageManager.DONT_KILL_APP); }
Example 20
Source File: MainActivity.java From WechatUnrecalled with GNU General Public License v3.0 | 4 votes |
private void toggleLauncherIcon(boolean newValue) { PackageManager packageManager = this.getPackageManager(); int state = newValue ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; packageManager.setComponentEnabledSetting(getIconComponentName(), state, PackageManager.DONT_KILL_APP); }