本文整理汇总了Java中android.content.pm.PackageManager.getApplicationEnabledSetting方法的典型用法代码示例。如果您正苦于以下问题:Java PackageManager.getApplicationEnabledSetting方法的具体用法?Java PackageManager.getApplicationEnabledSetting怎么用?Java PackageManager.getApplicationEnabledSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.pm.PackageManager
的用法示例。
在下文中一共展示了PackageManager.getApplicationEnabledSetting方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isFrozen
import android.content.pm.PackageManager; //导入方法依赖的package包/类
public boolean isFrozen(Context context) {
if (mFrozen == null) {
PackageManager pm = context.getPackageManager();
boolean enabled = false;
for (ApplicationInfo appInfo : mMapAppInfo.values())
try {
int setting = pm.getApplicationEnabledSetting(appInfo.packageName);
enabled = (enabled || setting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT);
enabled = (enabled || setting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
if (enabled)
break;
} catch (IllegalArgumentException ignored) {
}
mFrozen = !enabled;
}
return mFrozen;
}
示例2: Rule
import android.content.pm.PackageManager; //导入方法依赖的package包/类
private Rule(PackageInfo info, boolean wifi_blocked, boolean other_blocked, boolean changed, Context context) {
PackageManager pm = context.getPackageManager();
this.info = info;
this.name = info.applicationInfo.loadLabel(pm).toString();
this.system = ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
int setting = pm.getApplicationEnabledSetting(info.packageName);
if (setting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT)
this.disabled = !info.applicationInfo.enabled;
else
this.disabled = (setting != PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
this.wifi_blocked = wifi_blocked;
this.other_blocked = other_blocked;
this.changed = changed;
}
示例3: isEnabled
import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static boolean isEnabled(PackageInfo info, Context context) {
int setting;
try {
PackageManager pm = context.getPackageManager();
setting = pm.getApplicationEnabledSetting(info.packageName);
} catch (IllegalArgumentException ex) {
setting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
Log.w(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
}
if (setting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT)
return info.applicationInfo.enabled;
else
return (setting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}