代码如下:
// TODO: 该如何设置?
LocationManager lm;
lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
boolean GPS_status = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
boolean NETWORK_status = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
String status = "";
if(GPS_status){
status += "GPS 开启";
}else{
status += "GPS 未开启";
}
if(NETWORK_status){
status += "NETWORK 开启";
}else{
status += "NETWORK 未开启";
}
Toast.makeText(this,status,Toast.LENGTH_LONG).show();