需要检测GPS或者WiFi或者手机网络是否可用,我当前的代码可以检测出GPS。但是检测网络时就报错:
The method isProviderEnabled(String) in the type LocationManager is not applicable for the arguments (String, String)
代码:
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER, LocationManager.NETWORK_PROVIDER)){ Toast.makeText(this, "GPS is Enabled in your device", Toast.LENGTH_SHORT).show(); }else{ displayAlert(); }
相关分类