1. Disable app 

PackageManager packageManager = getPackageManager();
packageManager.setApplicationEnabledSetting("com.package.name", PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER, 0);


2. Enable app

PackageManager packageManager = getPackageManager();
packageManager.setApplicationEnabledSetting("com.package.name", PackageManager.PackageManager. COMPONENT_ENABLED_STATE_ENABLED, 0);


3. Restore previous status

PackageManager packageManager = getPackageManager();
packageManager.setApplicationEnabledSetting("com.package.name", PackageManager.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);

 

 

https://developer.android.com/reference/android/content/pm/PackageManager#setApplicationEnabledSetting(java.lang.String,%20int,%20int)

728x90
반응형

+ Recent posts