Java Android 6 Marshmallow Settings.Global.getInt for wifi总是返回错误的值?
在Android 6.0(API 23)棉花糖设备上读取WIFI_ON系统设置似乎总是返回0。此代码在19(Kit-kat)和较旧版本上运行良好。有没有理由不在安卓棉花糖上工作Java Android 6 Marshmallow Settings.Global.getInt for wifi总是返回错误的值?,java,android,Java,Android,在Android 6.0(API 23)棉花糖设备上读取WIFI_ON系统设置似乎总是返回0。此代码在19(Kit-kat)和较旧版本上运行良好。有没有理由不在安卓棉花糖上工作 //api level < 17 int wifiState = Settings.Secure.getInt(getContentResolver(), Settings.Secure.WIFI_ON, -1); //api levep 17+ int wifiState = Settings.Global.
//api level < 17
int wifiState = Settings.Secure.getInt(getContentResolver(), Settings.Secure.WIFI_ON, -1);
//api levep 17+
int wifiState = Settings.Global.getInt(getContentResolver(), Settings.Global.WIFI_ON, -1);
int mobileDataState = Settings.Global.getInt(getContentResolver(), "mobile_data", -1);
//api级别<17
int wifiState=Settings.Secure.getInt(getContentResolver(),Settings.Secure.WIFI_ON,-1);
//api等级17+
int wifiState=Settings.Global.getInt(getContentResolver(),Settings.Global.WIFI_ON,-1);
int mobileDataState=Settings.Global.getInt(getContentResolver(),“mobile_data”,-1);
对于移动数据状态,它从未被记录,所以这并不令人惊讶。在访问系统设置方面是否有任何记录在案的更改?getInt(ContentResolver cr,String name,int def)这是正确的格式吗?是的。我错过了“费比马修”