当前位置: 首页>>代码示例>>Java>>正文


Java PackageManager.COMPONENT_ENABLED_STATE_DISABLED属性代码示例

本文整理汇总了Java中android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED属性的典型用法代码示例。如果您正苦于以下问题:Java PackageManager.COMPONENT_ENABLED_STATE_DISABLED属性的具体用法?Java PackageManager.COMPONENT_ENABLED_STATE_DISABLED怎么用?Java PackageManager.COMPONENT_ENABLED_STATE_DISABLED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.content.pm.PackageManager的用法示例。


在下文中一共展示了PackageManager.COMPONENT_ENABLED_STATE_DISABLED属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyComponentEnablingState

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);
       }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:19,代码来源:SipService.java

示例2: isComponentEnabled

@SuppressWarnings("deprecation")
public static boolean isComponentEnabled(PackageManager manager, ComponentName component) {
    switch (manager.getComponentEnabledSetting(component)) {
        case PackageManager.COMPONENT_ENABLED_STATE_DISABLED:
            return false;
        case PackageManager.COMPONENT_ENABLED_STATE_ENABLED:
            return true;
        case PackageManager.COMPONENT_ENABLED_STATE_DEFAULT:
        default:
            try {
                PackageInfo packageInfo = manager.getPackageInfo(
                        component.getPackageName(),
                        PackageManager.GET_ACTIVITIES | PackageManager.GET_RECEIVERS | PackageManager.GET_SERVICES
                                | PackageManager.GET_PROVIDERS | PackageManager.GET_DISABLED_COMPONENTS);
                List<ComponentInfo> components = new ArrayList<>();
                if (packageInfo.activities != null) {
                    Collections.addAll(components, packageInfo.activities);
                }
                if (packageInfo.services != null) {
                    Collections.addAll(components, packageInfo.services);
                }
                if (packageInfo.providers != null) {
                    Collections.addAll(components, packageInfo.providers);
                }
                for (ComponentInfo componentInfo : components) {
                    if (componentInfo.name.equals(component.getClassName())) {
                        return componentInfo.isEnabled();
                    }
                }
                return false;
            } catch (PackageManager.NameNotFoundException e) {
                // the package isn't installed on the device
                return false;
            }
    }
}
 
开发者ID:Doist,项目名称:JobSchedulerCompat,代码行数:36,代码来源:DeviceTestUtils.java

示例3: resolveEnable

/**
 * 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);
    }
}
 
开发者ID:sfilmak,项目名称:MakiLite,代码行数:19,代码来源:Sharer.java

示例4: enableBootReceiver

private void enableBootReceiver(boolean value) {
    ComponentName receiver = new ComponentName(context, GlucosioBroadcastReceiver.class);
    PackageManager pm = context.getPackageManager();

    int componentState = value ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;

    pm.setComponentEnabledSetting(receiver,
            componentState,
            PackageManager.DONT_KILL_APP);
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:10,代码来源:GlucosioAlarmManager.java

示例5: setComponentState

public static void setComponentState(PackageManager pm, ComponentName componentName, boolean enable) {
    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);
    }
}
 
开发者ID:RikkaW,项目名称:Bridge,代码行数:9,代码来源:PackageManagerUtils.java

示例6: isComponentEnabled

public static boolean isComponentEnabled(PackageManager pm, String pkg, String cls) {
    ComponentName componentName = new ComponentName(pkg, cls);
    int componentEnabledSetting = pm.getComponentEnabledSetting(componentName);

    switch (componentEnabledSetting) {
        case PackageManager.COMPONENT_ENABLED_STATE_DISABLED:
            return false;
        case PackageManager.COMPONENT_ENABLED_STATE_ENABLED:
            return true;
        case PackageManager.COMPONENT_ENABLED_STATE_DEFAULT:
        default:
            // We need to get the application info to get the component's default state
            try {
                PackageInfo packageInfo = pm.getPackageInfo(pkg, PackageManager.GET_ACTIVITIES
                        | PackageManager.GET_RECEIVERS
                        | PackageManager.GET_SERVICES
                        | PackageManager.GET_PROVIDERS
                        | PackageManager.GET_DISABLED_COMPONENTS);

                List<ComponentInfo> components = new ArrayList<>();
                if (packageInfo.activities != null) Collections.addAll(components, packageInfo.activities);
                if (packageInfo.services != null) Collections.addAll(components, packageInfo.services);
                if (packageInfo.providers != null) Collections.addAll(components, packageInfo.providers);

                for (ComponentInfo componentInfo : components) {
                    if (componentInfo.name.equals(cls)) {
                        return componentInfo.enabled; //This is the default value (set in AndroidManifest.xml)
                        //return componentInfo.isEnabled(); //Whole package dependant
                    }
                }

                // the component is not declared in the AndroidManifest
                return false;
            } catch (PackageManager.NameNotFoundException e) {
                // the package isn't installed on the device
                return false;
            }
    }
}
 
开发者ID:RikkaW,项目名称:Bridge,代码行数:39,代码来源:PackageManagerUtils.java

示例7: enableSMSReceiving

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);
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:11,代码来源:DefaultSMSAppHelper.java

示例8: wasComponentEnabled

/**
 * 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;
}
 
开发者ID:Leanplum,项目名称:Leanplum-Android-SDK,代码行数:21,代码来源:LeanplumManifestHelper.java

示例9: canDownloadState

private static boolean canDownloadState(Context ctx) {
    try {
        int state = ctx.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;
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:15,代码来源:UpdateUtils.java

示例10: saveConfiguration

private void saveConfiguration() throws JSONException {
	PackageManager pm = getPackageManager();
	ComponentName componentName = new ComponentName("com.bluewatcher", "com.bluewatcher.BootupLoader");
	int state = PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
	if( !startAtBoot.isChecked() )
		state = PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
	pm.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP);
	ConfigurationManager.getInstance().save(RECONNECT_MESSAGE_CONFIG, Boolean.toString(showReconnectMessage.isChecked()));
	ConfigurationManager.getInstance().save(SEND_CONTROL_MODE, Boolean.toString(sendControlMode.isChecked()));
	ConfigurationManager.getInstance().save(GBA400_CLEAN_NOTIFICATION, Boolean.toString(gba400CleanNotification.isChecked()));
	ConfigurationManager.getInstance().save(DISABLE_SERVER_SERVICES, Boolean.toString(disableServer.isChecked()));
}
 
开发者ID:masterjc,项目名称:bluewatcher,代码行数:12,代码来源:SettingsActivity.java

示例11: onSharedPreferenceChanged

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    if (key.equals(PREFERENCES_REPLY_LOCATION_REQUESTS_ALWAYS_KEY)) {
        boolean replyAlways = sharedPreferences.getBoolean(PREFERENCES_REPLY_LOCATION_REQUESTS_ALWAYS_KEY, false);
        int state = replyAlways ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
        ComponentName receiver = new ComponentName(this, SmsUpdateReceiver.class);
        this.getPackageManager().setComponentEnabledSetting(receiver, state, PackageManager.DONT_KILL_APP);
    } else if (key.equals(PREFERENCES_SMS_LIMIT_KEY) && generalPreferenceFragment != null) {
        String newSummary = generalPreferenceFragment.getSmsLimitSummary();
        generalPreferenceFragment.findPreference(PREFERENCES_SMS_LIMIT_KEY).setSummary(newSummary);
    }
}
 
开发者ID:gvinciguerra,项目名称:custode,代码行数:12,代码来源:SettingsActivity.java

示例12: onSharedPreferenceChanged

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Preference pref = findPreference(key);
    setSummary(pref, true);
    switch (key) {
        case "is_telnet":
            // start/stop telnetd
            EnvUtils.execService(getBaseContext(), "telnetd", null);
            break;
        case "telnet_port":
            // restart httpd
            EnvUtils.execService(getBaseContext(), "httpd", "restart");
        case "telnet_localhost":
            // restart telnetd
            EnvUtils.execService(getBaseContext(), "telnetd", "restart");
            break;
        case "is_http":
            // start/stop httpd
            EnvUtils.execService(getBaseContext(), "httpd", null);
            break;
        case "http_port":
        case "http_conf":
            // restart httpd
            EnvUtils.execService(getBaseContext(), "httpd", "restart");
            break;
        case "autostart":
            // set autostart settings
            int autostartFlag = (PrefStore.isAutostart(this) ?
                    PackageManager.COMPONENT_ENABLED_STATE_ENABLED
                    : PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
            ComponentName bootComponent = new ComponentName(this, BootReceiver.class);
            getPackageManager().setComponentEnabledSetting(bootComponent, autostartFlag,
                    PackageManager.DONT_KILL_APP);
            break;
        case "nettrack":
            // set handler for network change action
            int nettrackFlag = (PrefStore.isTrackNetwork(this) ?
                    PackageManager.COMPONENT_ENABLED_STATE_ENABLED
                    : PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
            ComponentName networkComponent = new ComponentName(this, NetworkReceiver.class);
            getPackageManager().setComponentEnabledSetting(networkComponent, nettrackFlag,
                    PackageManager.DONT_KILL_APP);
            break;
        case "stealth":
            // set stealth mode
            // Run app without launcher: am start -n ru.meefik.linuxdeploy/.MainActivity
            int stealthFlag = (PrefStore.isStealth(this) ?
                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED
                    : PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
            ComponentName mainComponent = new ComponentName(getPackageName(), getPackageName() + ".Launcher");
            getPackageManager().setComponentEnabledSetting(mainComponent, stealthFlag,
                    PackageManager.DONT_KILL_APP);
            break;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:55,代码来源:SettingsActivity.java


注:本文中的android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。