Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Can';t检测API 25中是否启用了开发人员选项?_Java_Android - Fatal编程技术网

Java Can';t检测API 25中是否启用了开发人员选项?

Java Can';t检测API 25中是否启用了开发人员选项?,java,android,Java,Android,在Android Studio emulator(仅API 25)中,我无法检测是否启用了开发人员选项 此代码始终返回true,即使未启用开发人员选项。。。我怎样才能解决这个问题 int developerOptions = Settings.Secure.getInt(this.getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED , 0); 我尝试了Settings.Global.getInt(this.get

在Android Studio emulator(仅API 25)中,我无法检测是否启用了开发人员选项

此代码始终返回true,即使未启用开发人员选项。。。我怎样才能解决这个问题

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

我尝试了
Settings.Global.getInt(this.getContentResolver(),Settings.Global.DEVELOPMENT\u Settings\u ENABLED,0)但我仍然遇到同样的问题。

应该在设备16的下一行中完成(这是您的情况,这就是它失败的原因)

作为替代方案。你应该1。在真实的设备上尝试,因为仿真器的不同金鱼状态可能会影响您的响应

更新。

二,。调用开发者选项的
活动
。如果它失败了,它应该被禁用。当它存在时,您不需要打开它,并且可以立即关闭它。例如

try {
    startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS), 8080);
    // You might also post a delay for finishing activity. 
    finishActivity(8080);

    // Activity exist behavior
} catch (Exception e) {
    // Disabled Developer options
}

第一个解决方案不适用于Android Studio emulator上的API 25,请尝试out@Bandy尝试其他解决方案,也可以尝试不使用仿真器。这就是它在本地的完美工作方式。第二个解决方案不适合华为设备,我已经尝试过了:/@Bandy您也可以尝试最后一个。但最后一个解决方案会打开一个新活动。我不想打开一个新的活动,我只想检查一下
int result = Settings.Secure.getInt(this.getContentResolver(),
                Settings.Global.DEVELOPMENT_SETTINGS_ENABLED , 0);
try {
    startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS), 8080);
    // You might also post a delay for finishing activity. 
    finishActivity(8080);

    // Activity exist behavior
} catch (Exception e) {
    // Disabled Developer options
}