有没有什么办法打开GPS服务,通过code?
is there any way to turn on gps service through code?
有一个关于HelloAndroid
检查为GPS
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L,1.0f, this);
boolean isGPS = locationManager.isProviderEnabled (LocationManager.GPS_PROVIDER);
如果isGPS是假打开设置
If isGPS is false open the settings
startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);
不要忘记检查GPS已启用,当用户返回时,他们可能不会启用它。
Don't forget to check the GPS is enabled when the user returns, they might not enable it.