1. 得到LocationManager
LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
2. 通过LocationManager查看GPS以及Network是否开启
boolean gpsStatus = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
boolean networkStatus = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if(gpsStatus){
//GPS 开启
} else{
//GPS 关闭
}
if(networkStatus ){
//Network 开启
} else{
//Network 关闭
}