Created
August 22, 2014 00:16
-
-
Save chrislacy/4e373420f1c1b74aa481 to your computer and use it in GitHub Desktop.
Disabling Activity (after verifying purchase)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
ComponentName componentName = new ComponentName(getPackageName(), YourActivity.class.getName()); | |
PackageManager packageManager = getApplicationContext().getPackageManager(); | |
if (licenseState == LICENSE_VALID) { | |
if (packageManager.getComponentEnabledSetting(componentName) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED) { | |
packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); | |
} | |
} else if (licenseState == LICENSE_INVALID) { | |
packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); | |
} | |
} catch (Exception ex) { | |
// Be sure to trap any and all potential issues with the above code. | |
// It's not critical that it succeeds. | |
Log.d(TAG, "Disabling component failed", ex); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment