第一种:
try {
Runtime runtime = Runtime.getRuntime();
runtime.exec("pm disable " + “com.example.disableapp1”);
} catch (Exception e) {
e.getStackTrace();
}
adb shell pm enable com.example.disableapp1
第二种:
public static void disableApplication(Context context){
android.content.pm.PackageManager mPackageManager=context.getPackageManager();
mPackageManager.setApplicationEnabledSetting(applicationName,android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED,android.content.pm.PackageManager.DONT_KILL_APP);
}
public static void enableApplication(android.content.Context context){
android.content.pm.PackageManager mPackageManager=context.getPackageManager();
mPackageManager.setApplicationEnabledSetting(applicationName, android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED, android.content.pm.PackageManager.DONT_KILL_APP);
}