My mobile does not move, but gps lat long values ​​still change

My mobile does not move, but the lat/long GPS values ​​are constantly changing, so?

How to fix this problem? How to get reliable long lat values ​​of my mobile ... I use the following code to get GPS locations:

  public Location getLocation() { try { locationManager = (LocationManager) mContext .getSystemService(LOCATION_SERVICE); // getting GPS status isGPSEnabled = locationManager .isProviderEnabled(LocationManager.GPS_PROVIDER); // getting network status isNetworkEnabled = locationManager .isProviderEnabled(LocationManager.NETWORK_PROVIDER); if (!isGPSEnabled && !isNetworkEnabled) { // no network provider is enabled } else { this.canGetLocation = true; if (isGPSEnabled) { locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this); // Log.d("GPS Enabled", "GPS Enabled"); if (locationManager != null) { location = locationManager .getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location != null) { latitude = location.getLatitude(); longitude = location.getLongitude(); } } } if (isNetworkEnabled) { locationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this); // Log.d("Network", "Network"); if (locationManager != null) { location = locationManager .getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (location != null) { latitude = location.getLatitude(); longitude = location.getLongitude(); } } } // if GPS Enabled get lat/long using GPS Services } } catch (Exception e) { e.printStackTrace(); } return location; } 
+4
source share
1 answer

There are many reasons that can do this, and this is probably not a problem at all.

Sometimes it is only your GPS that gets the best correction for your location, or the location provider may have changed.

PS: The accuracy is not so good, so your location may change from time to time. As you can see on this link . And you can get your location from 6 different sources, each of which has a different accuracy.

  • Cached GPS.

Most androids have the ability to store the latest to know the GPS location. This is usually used when the application starts first, and you can get the timestamp, latitude, longitude, and accuracy.

Code example:

 locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); 
  1. Cached network.

    Android devices can also store the last known location as determined by the service provider of the network of cellular operators. The provider collects information from the cellular network and Wi-Fi, if enabled, then sends it to the remote server process, which compresses the information and sends the approximate location. It is not available in all countries. Like GPS, you usually get timestamp, latitude, longitude, and accuracy.

Code example:

 locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); 
  1. GPS in real time.

This is the raw information transmitted from GPS. When the GPS is first turned on, it does not immediately return any information, it must first be warmed up. The warm-up time depends on the device and can usually take from one minute or longer if you are inside the building. A little more about this. Depending on what your provider allows, you can access the timestamp, latitude, longitude, altitude, carrier, speed, accuracy and distance traveled.

Code example:

 locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,time,distance,listener); 
  1. Network in real time.

This is the network data source provider information returned by a cellular medium, such as AT&T in the United States. Different carriers use different location information such as WiFi data, GPS information, nearby cell towers, etc. Depending on what your media allows, you can access the timestamp, latitude, longitude, altitude, accuracy, and distance traveled.

Code example:

 locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,time,distance,listener); 
  1. Passive

This setting means that your application can listen for location updates while it is in a minimized state. The idea is to save battery power so that your application providers run at full speed ahead while the application is minimized. This will be a huge battery drain. A passive location may listen to another application to request location updates. You can access timestamp, latitude, longitude, altitude and accuracy. As far as I know, you will not be able to determine from which provider this information was obtained.

Code example:

 <receiver android:name=".PassiveLocationChangedReceiver" android:enabled="true"/> 
  1. NMEA

Although it is not human readable, you can access the NMEA source lines. Typically, these lines are used for programmatic access and only make sense to the developer or engineer. This data is often used in marine applications. Data is available only after warming up the GPS.

Source: This information was taken from here .

In addition, there are some very common sources of errors when getting location, as you can see in android docs:

Getting a user’s location from a mobile device can be difficult. There are several reasons why reading a location (regardless of the source) may contain errors and be inaccurate. Some sources of errors in the user's location include:

  • Many sources of location

GPS, Cell-ID and Wi-Fi can give an idea of ​​the location of users. Determining what to use and trust is a matter of compromising accuracy, speed, and battery performance.

  • User movement

As the user's location changes, you must consider the movement of re-evaluating the user's location so often.

  • Important accuracy

Location estimates from each location source are incompatible in their accuracy. A place obtained 10 seconds ago from one source may be more accurate than the newest place from another or the same source.

Please take a moment to read "Location Strategies" from Google.

Read more about LocationManager here .

+6
source

All Articles