如何检查GPS Sensor当前是否读取信号?
如何检查 GPS 是否正在读取信号。我写了一段代码来检查GPS是否启用。
private void systemService() {
locMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if(!locMgr.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
AlertDialog.Builder noGps = new AlertDialog.Builder(this);
noGps.setMessage("GPS is off. Please turn it on and restart your Application.");
noGps.show();
}// end of if
}// end of systemsService();
但是,即使启用它,GPS 传感器也需要几分钟或几秒钟才能接收信号。
我的问题是:如何检查 GPS 传感器当前是否正在接收信号?
How to check if the GPS is reading a signal. I have written a code to check whether the GPS is enabled or not.
private void systemService() {
locMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if(!locMgr.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
AlertDialog.Builder noGps = new AlertDialog.Builder(this);
noGps.setMessage("GPS is off. Please turn it on and restart your Application.");
noGps.show();
}// end of if
}// end of systemsService();
But, even when it is enabled it takes few minutes or seconds the GPS sensor to receive the signal.
Myy question is: how to check if the GPS sensor is currently receiving a signal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,你不能。
您可以使用
runOnFirstFix
在可用时使用位置数据,还可以使用 requestLocationUpdates。As far as I know, you can't.
You can use
runOnFirstFix
to use location data when available, and also define an update interval with requestLocationUpdates.