• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android get GPS coordinates through offline APP

Android get GPS coordinates through offline APP

  • because of the code error

    Votes: 0 0.0%
  • may be it s not possible in the offline

    Votes: 0 0.0%

  • Total voters
    0
  • Poll closed .
Working on a Android app that gets the GPS co ordinates.
1. Want to know if the GPS app works offline(Used a source code it sometimes displays GPS coordinates but some time it does not).
2. Please share me any link to any working source code to try it from my side.....
 
Working on a Android app that gets the GPS co ordinates.
1. Want to know if the GPS app works offline(Used a source code it sometimes displays GPS coordinates but some time it does not).
2. Please share me any link to any working source code to try it from my side.....


If your are using LocationManager's requestLocationUpdates(), then, in my recent experience the GPS chip sometimes does not get a location. Rather than use getLastKnownLocation(), which can contain really stale coordinates, I'd rather not display them because they are misleading.

You might also want to implement getAccuracy(), here in L.A. and in open space, I regularly get an accuracy of <10 meters, which is adequate. If you in a tree lined blvd or have tall buildings around you, do you really want to display the coordinates if the accuracy is >25 meters?

When you say "offline", do you mean you want to run it on a separate thread? Be mindful of the battery life and shut down the thread if you do not need it anymore.

How often do you update your coordinates?

There are lots of codes on stackoverflow.com
 
Last edited:
If your are using LocationManager's requestLocationUpdates(), then, in my recent experience the GPS chip sometimes does not get a location. Rather than use getLastKnownLocation(), which can contain really stale coordinates, I'd rather not display them because they are misleading.

When you say "offline", do you mean you want to run it on a separate thread?

No I think he means with no Internet connection.

I would say GPS does work offline, because when I use Google satnav, it can direct me to my destination without having a data connection.
 
I would say GPS does work offline, because when I use Google satnav, it can direct me to my destination without having a data connection.[/QUOTE]


This code works for me, but you might not want to update it every second or every 5 meters.
Code:
  locationmanager = (LocationManager) getSystemService(LOCATION_SERVICE);
  // mylocation = locationmanager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
  locationmanager.requestLocationUpdates(
  LocationManager.GPS_PROVIDER, 1000, 5, new LocationListener() {
  @Override
  public void onLocationChanged(Location newlocation) {
  // callback with the new location data
  latitude = String.valueOf(newlocation.getLatitude());
  longitude = String.valueOf(newlocation.getLongitude());
  accuracy = String.valueOf(newlocation.getAccuracy());
  Toast.makeText(getApplicationContext(),
  "Latitude:Longitude = "+latitude+" : "+longitude,
  Toast.LENGTH_LONG).show();
  }
 
If u can't find an in stackoverflow for ur purposes, I'll walk u through step-by step.
But I still use SDK22 and android.location.LocationListener rather than com.google.android.gms.location.LocationListener;
 
Back
Top Bottom