How can I check if the user has developer option enabled on its device? (not with adb comunication active, or debug USB active, I need to know only if Developer Option are enabled).
I've tried this solution: How to check programmatically whether app is running in debug mode or not? but it doesn't work for me. Thanks in advance
try this:
int adb = Settings.Secure.getInt(this.getContentResolver(),
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED , 0);
You should use getInt or another in Settings.Global with DEVELOPMENT_SETTINGS_ENABLED
Edit : Below API 17, it is the same but with Settings.Secure
Here's a method that returns true if developer mode is enabled for all devices at Android 4.1 or above (API 16), returns false if developer mode is not enabled on such devices, and returns false on all earlier Android devices down to 1.0.
@android.annotation.TargetApi(17) public boolean isDevMode() {
if(Integer.valueOf(android.os.Build.VERSION.SDK) == 16) {
return android.provider.Settings.Secure.getInt(getApplicationContext().getContentResolver(),
android.provider.Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED , 0) != 0;
} else if (Integer.valueOf(android.os.Build.VERSION.SDK) >= 17) {
return android.provider.Settings.Secure.getInt(getApplicationContext().getContentResolver(),
android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED , 0) != 0;
} else return false;
}
来源:https://stackoverflow.com/questions/31581830/android-how-to-check-if-developer-option-is-enabled