秋梦无痕

一场秋雨无梦痕,春夜清风冻煞人。冬来冷水寒似铁,夏至京北蟑满城。

Avatar

[Android]如何在app中禁用/启用别的app?

final PackageManager pm = mContext.getPackageManager();
if (PackageManager.COMPONENT_ENABLED_STATE_DISABLED !=
        pm.getApplicationEnabledSetting(app)) {
    pm.setApplicationEnabledSetting(app,
        PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
} else {
    pm.setApplicationEnabledSetting(app,
        PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0);
}