如何检查GPS接收机的当前状态?如何检查GPS接收机的当前状态?我已经查过了LocationListener onStatusChanged方法,但不知何故,它似乎不起作用,或只是错误的可能性。基本上,我只需要知道,在屏幕顶部的GPS图标是闪烁(没有实际的修复)或固体(修复是可用的)。
3 回答
宝慕林4294392
TA贡献2021条经验 获得超8个赞
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");intent.putExtra("enabled", true);sendBroadcast(intent);
Intent intent = new Intent("android.location.GPS_FIX_CHANGE");intent.putExtra("enabled", true);sendBroadcast(intent);
Intent intent = new Intent("android.location.GPS_FIX_CHANGE");intent.putExtra("enabled", false);sendBroadcast(intent);
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");intent.putExtra("enabled", false);sendBroadcast(intent);
// MyReceiver must extend BroadcastReceiverMyReceiver receiver = new MyReceiver(); IntentFilter filter = new IntentFilter("android.location.GPS_ENABLED_CHANGE"); filter.addAction("android.location.GPS_FIX_CHANGE");registerReceiver(receiver, filter);
森栏
TA贡献1810条经验 获得超5个赞
isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < (GPS_UPDATE_INTERVAL * 2);
- 3 回答
- 0 关注
- 578 浏览
添加回答
举报
0/150
提交
取消