Android - How to check if Developer option is enabled

人走茶凉 提交于 2019-12-30 06:33:34

问题


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


回答1:


try this:

int adb = Settings.Secure.getInt(this.getContentResolver(),
                Settings.Global.DEVELOPMENT_SETTINGS_ENABLED , 0);



回答2:


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




回答3:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!