* h6. What * We should expose a function that allows the end developer to check if the underlying device has the developer options enabled.
h6. Why Requiring the developer options to be enabled is a prerequisite for enabling other functions on the device that can be used to carry out malicious actions.
* h6. How *
Implement a function similar to below that will perform a check using the Android Settings class to check if the device has the developer options enabled.
{code:java} /** * Detect if the developer options mode is enabled on the device */ public void detectDeveloperOptions() { int devOptionsEnabled = Settings.Secure.getInt(context.getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
if (devOptionsEnabled > 0) { return true; } else { return false; } } {code} |
|