PackageManager getComponentEnabledSetting - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for PackageManager getComponentEnabledSetting method.

This code example shows how to use the following methods:checkSignatures, getComponentEnabledSetting, resolveService
	 * @return true if ads should be hidden 
	 */ 
	public static boolean hideAds(final Context context) {
		PackageManager pm = context.getPackageManager();
		Intent donationCheck = new Intent(DONATOR_BROADCAST_CHECK);
		ResolveInfo ri = pm.resolveService(donationCheck, 0);
		// Log.d(TAG, "ri: " + ri); 
		int match = PackageManager.SIGNATURE_UNKNOWN_PACKAGE;
		if (ri != null) {
			Log.d(TAG, "found package: " + ri.serviceInfo.packageName);
			ComponentName cn = new ComponentName(ri.serviceInfo.packageName, ri.serviceInfo.name);
			// Log.d(TAG, "component name: " + cn); 
			int i = pm.getComponentEnabledSetting(cn);
			// Log.d(TAG, "component status: " + i); 
			// Log.d(TAG, "package status: " + ri.serviceInfo.enabled); 
			if (i == PackageManager.COMPONENT_ENABLED_STATE_ENABLED
					|| i == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
					&& ri.serviceInfo.enabled) {
				match = pm.checkSignatures(context.getPackageName(), ri.serviceInfo.packageName);
			} else { 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getComponentEnabledSetting
 
    public static boolean isComponentEnabled(@NotNull Context context,
                                             @NotNull Class<? extends Context> componentClass) {
        final PackageManager pm = context.getPackageManager();
 
        int componentEnabledSetting = pm.getComponentEnabledSetting(new ComponentName(context, componentClass));
        return componentEnabledSetting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED || componentEnabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
    } 
 
    public static String saveBitmap(@NotNull Bitmap bitmap,
                                    @NotNull String path,
                                    @NotNull String fileName) {
        final File filePath = new File(path);
        filePath.mkdirs();
 
        final File file = new File(path, fileName);
        if (!file.exists()) {
            final String name = file.getAbsolutePath();
 
            FileOutputStream fos = null;
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getComponentEnabledSetting
 
	public static boolean isComponentEnabled(@Nonnull Context context,
											 @Nonnull Class<? extends Context> componentClass) {
		final PackageManager pm = context.getPackageManager();
 
		int componentEnabledSetting = pm.getComponentEnabledSetting(new ComponentName(context, componentClass));
		return componentEnabledSetting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED || componentEnabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
	} 
 
	public static String saveBitmap(@Nonnull Bitmap bitmap,
									@Nonnull String path,
									@Nonnull String fileName) {
		final File filePath = new File(path);
		filePath.mkdirs();
 
		final File file = new File(path, fileName);
		if (!file.exists()) {
			final String name = file.getAbsolutePath();
 
			FileOutputStream fos = null;
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getComponentEnabledSetting
		abortBroadcast();
	} 
 
	public static boolean isBlocking(Context context) {
		PackageManager pm = context.getPackageManager();
		return pm.getComponentEnabledSetting(BLOCKER) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
	} 
 
	public static void toggleBlocking(Context context) {
		if (Params.LOGGING_ENABLED) { 
			Log.i(Params.LOGGING_TAG, "Toggling MEDIA_BUTTON blocking.");
		} 
 
		PackageManager pm = context.getPackageManager();
		int newState = (isBlocking(context)) ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED
				: PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
		pm.setComponentEnabledSetting(BLOCKER, newState, PackageManager.DONT_KILL_APP);
	} 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getComponentEnabledSetting
		} 
	} 
 
	public static boolean isReceiverEnabled(Context context) {
		PackageManager packageManager = context.getPackageManager();
		int bootCompletedReceiverState = packageManager.getComponentEnabledSetting(new ComponentName(context, BootCompletedReceiver.class));
		return bootCompletedReceiverState != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
	} 
 
	public static void setReceiverEnabled(boolean enabled, Context context) {
		int enabledState = enabled ? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
		ComponentName bootCompletedReceiverName = new ComponentName(context, BootCompletedReceiver.class);
		context.getPackageManager().setComponentEnabledSetting(bootCompletedReceiverName, enabledState, PackageManager.DONT_KILL_APP);
	} 
 
} 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getComponentEnabledSetting, setComponentEnabledSetting
    } 
 
    private static boolean setActivityState(final Context context,
            final ComponentName activityComponent, final int activityState) {
        final PackageManager pm = context.getPackageManager();
        final int activityComponentState = pm.getComponentEnabledSetting(activityComponent);
        if (activityComponentState == activityState) {
            return false; 
        } 
        pm.setComponentEnabledSetting(
                activityComponent, activityState, PackageManager.DONT_KILL_APP);
        return true; 
    } 
} 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getComponentEnabledSetting, setComponentEnabledSetting
        } 
    } 
 
    public static void setServicesEnabled(Context context, boolean enabled) {
        PackageManager pm = context.getPackageManager();
        if (!enabled && pm.getComponentEnabledSetting(new ComponentName(context, MailService.class)) ==
                PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
            /* 
             * If no accounts now exist but the service is still enabled we're about to disable it 
             * so we'll reschedule to kill off any existing alarms. 
             */ 
            MailService.actionReschedule(context);
        } 
        pm.setComponentEnabledSetting(
                new ComponentName(context, MessageCompose.class),
                enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED :
                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
        pm.setComponentEnabledSetting(
                new ComponentName(context, AccountShortcutPicker.class),

4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getComponentEnabledSetting, setComponentEnabledSetting
        } 
    } 
 
    public static void setServicesEnabled(Context context, boolean enabled) {
        PackageManager pm = context.getPackageManager();
        if (!enabled && pm.getComponentEnabledSetting(new ComponentName(context, MailService.class)) ==
                PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
            /* 
             * If no accounts now exist but the service is still enabled we're about to disable it 
             * so we'll reschedule to kill off any existing alarms. 
             */ 
            MailService.actionReschedule(context);
        } 
        pm.setComponentEnabledSetting(
                new ComponentName(context, MessageCompose.class),
                enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED :
                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
        pm.setComponentEnabledSetting(
                new ComponentName(context, AccountShortcutPicker.class),

4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getComponentEnabledSetting
        wrapped.setComponentEnabledSetting(componentName, newState, flags);
    } 
 
    @Override 
    public int getComponentEnabledSetting(ComponentName componentName) {
        return wrapped.getComponentEnabledSetting(componentName);
    } 
 
    @Override 
    public void setApplicationEnabledSetting(String packageName, int newState, int flags) {
        wrapped.setApplicationEnabledSetting(packageName, newState, flags);
    } 
     
    @Override 
    public int getApplicationEnabledSetting(String packageName) {
        return wrapped.getApplicationEnabledSetting(packageName);
    } 
 
    @Override 
    public void addPreferredActivity(IntentFilter filter,
4
CodeRank
Experience pair programming with AI  Get Codota for Java

Related PackageManager getComponentEnabledSetting Questions & Answers:

getComponentEnabledSetting Method Overview
Return the the enabled setting for a package component (activity, receiver, service, provider).
See Code Examples for other Android PackageManager Methods: