本文整理匯總了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);
}