0

I have a function that checks if developer mode is enabled or not, as the suggestion here:

Android - How to check if Developer option is enabled

Here is the code:

public boolean isDevMode() {
    if(Build.VERSION.SDK_INT >= 17) {
        return android.provider.Settings.Global.getInt(getApplicationContext().getContentResolver(),
                Settings.Global.DEVELOPMENT_SETTINGS_ENABLED , 0) != 0;
    } else {
        return false;
    }
}

It works perfectly on API 26+ but I've just tested it on the emulator on API 24 and it returns false regardless of if developer settings are enabled or not.

What am I missing? Is it a different option for < 26?

Morteza Jalambadani
  • 2,190
  • 6
  • 21
  • 35
sS3tYo
  • 21
  • 5

1 Answers1

0

Fixed it by changing the default value to true for builds under oreo only.

public boolean isDevMode() {
   if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        return Settings.Secure.getInt(context.getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
   } else {
        return Settings.Secure.getInt(context.getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1) != 0;
   }
}
sS3tYo
  • 21
  • 5