启动Android的GPS服务 [英] start Android gps service
本文介绍了启动Android的GPS服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有什么办法打开GPS服务,通过code?
is there any way to turn on gps service through code?
推荐答案
有一个关于<一个很好的例子href="http://www.helloandroid.com/tutorials/calling-system-settings-android-app-gps-example">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.
这篇关于启动Android的GPS服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文