How to test GPS status?

谁说我不能喝 提交于 2019-12-02 11:45:59

Look at LocationManager, GPS status is about the GPS engine itself not location notifications and is not reliable on all platforms/devices even to determine if you have/had a fix.

Or alternatively an older but still relevant tutorial

When the onGpsStatusChanged() is called from the framework it means that there is a valid gps status update. Use getGpsStatus() to retrieve the latest GPS status updates.

public void onGpsStatusChanged(int event) {
        if (event == GpsStatus.GPS_EVENT_STARTED) {
            Log.d(TAG , "GPS event started ");

        } else if (event == GpsStatus.GPS_EVENT_STOPPED) {
            Log.d(TAG , "GPS event stopped ");

        } else if (event == GpsStatus.GPS_EVENT_FIRST_FIX) {

            GpsStatus gs = locationManager.getGpsStatus(null);

You can use the above snippet. Note that some of the data you want is in the GpsStatus structure.

The rest of the info you require like new location can be obtained from the onLocationChanged() callback.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!