1. Download our Official Android App: Forums for Android!

Apps Android get GPS coordinates through offline APP

Discussion in 'Android Development' started by princethomas1990, Jul 29, 2016.

?

Android get GPS coordinates through offline APP

Poll closed Aug 5, 2016.
  1. because of the code error

    0 vote(s)
    0.0%
  2. may be it s not possible in the offline

    0 vote(s)
    0.0%
Multiple votes are allowed.
  1. princethomas1990

    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    4
    Joined:
    Jul 29, 2016

    Jul 29, 2016
    4
    1
    16
    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.....
     

    Advertisement

  2. scary alien

    scary alien not really so scary
    Moderator
    Rank:
     #9
    Points:
    2,138
    Posts:
    22,282
    Joined:
    Mar 5, 2010

    Mar 5, 2010
    22,282
    23,583
    2,138
    Male
    space alien ;)
    Indy
    Welcome to AF! :)

    I've moved your thread over here to our Application Development area for you.

    Cheers!
     
  3. ac4android

    ac4android Well-Known Member
    Rank:
    None
    Points:
    53
    Posts:
    198
    Joined:
    Nov 3, 2015

    Nov 3, 2015
    198
    29
    53

    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
     
    #3 ac4android, Jul 29, 2016
    Last edited: Jul 29, 2016
  4. LV426

    LV426 I say we take off and nuke this place from orbit
    Moderator
    Rank:
     #17
    Points:
    1,488
    Posts:
    6,714
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    6,714
    9,436
    1,488
    Male
    Software developer
    South West of England
    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.
     
    princethomas1990 likes this.
  5. ac4android

    ac4android Well-Known Member
    Rank:
    None
    Points:
    53
    Posts:
    198
    Joined:
    Nov 3, 2015

    Nov 3, 2015
    198
    29
    53
    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 (Text):
    1.  
    2.   locationmanager = (LocationManager) getSystemService(LOCATION_SERVICE);
    3.   // mylocation = locationmanager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    4.   locationmanager.requestLocationUpdates(
    5.   LocationManager.GPS_PROVIDER, 1000, 5, new LocationListener() {
    6.   @Override
    7.   public void onLocationChanged(Location newlocation) {
    8.   // callback with the new location data
    9.   latitude = String.valueOf(newlocation.getLatitude());
    10.   longitude = String.valueOf(newlocation.getLongitude());
    11.   accuracy = String.valueOf(newlocation.getAccuracy());
    12.   Toast.makeText(getApplicationContext(),
    13.   "Latitude:Longitude = "+latitude+" : "+longitude,
    14.   Toast.LENGTH_LONG).show();
    15.   }
    16.  
     
    scary alien likes this.
  6. ac4android

    ac4android Well-Known Member
    Rank:
    None
    Points:
    53
    Posts:
    198
    Joined:
    Nov 3, 2015

    Nov 3, 2015
    198
    29
    53
    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;
     
    scary alien likes this.
  7. princethomas1990

    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    4
    Joined:
    Jul 29, 2016

    Jul 29, 2016
    4
    1
    16
    Thanks guys for your support i used the same kinda code it worked for me....
     
    scary alien likes this.

Share This Page

Loading...