0

I am going to develop an Application where i need to retrieve the current Location of the User into Application in order to fetch data for specific location. Before starting into this I would like to learn how a GPS system works for Android & what is the relation with WiFi . Can anybody tell me complete explanation about GPS & Geo Code in reference of Android devices & suggest me how I need to start with.

Jay Mayu
  • 17,023
  • 32
  • 114
  • 148
Suresh Sharma
  • 1,826
  • 22
  • 41
  • Lie Ryna, talonmies @ there is an apparent thought behind asking this question. I just wanted to know about how the GPS works in Android Smart phones & i must have knowledge about all the dependencies So that it will not produce any complication later on. Thanks. – Suresh Sharma Mar 18 '13 at 12:32

3 Answers3

5

Android has three ways of getting the current location of the user.

  1. Through WI-FI
  2. Through your networkprovider.
  3. Through the GPS chip in Android Device.

Out of these the most accurate method is to get the co-ordinates from GPS. This will get your accurate location in lat longs but it will also use most of the battery. This is generally used in navigation maps where accuracy is Important.

the rest of the two methods are less accurate but also use less battery. If the accuracy of current location is not that important you can use the later two.All of these methods are available through LocationManager of android.

EDIT:

        // To get Updates From GPS Use
    mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
            currentlocation); 

       //To get Updates From network Use
    mlocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
            currentlocation);
Parvaz Bhaskar
  • 1,367
  • 9
  • 29
  • Thanks very much for your answer. may i ask you that how can i get the current location by using WiFi connection only. how much it is suitable & how it is suppose to be inaccurate or harmfull for application. – Suresh Sharma Mar 13 '13 at 06:14
  • We use GPS provider generally for navigation purposes. If your app doesn't have that kind of requirement and you only want to show general information of surroundings then you should opt for location updates through Network Provider. This way you will get inaccurate current location even when there is no wifi around. You will get your location updates by using the Network Provider.LocationListener currentlocation = new CurrentLocation(); mlocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,currentlocation); – Parvaz Bhaskar Mar 13 '13 at 06:22
4

GPS

These days most Android smartphone have AGPS chips installed.AGPS means Assisted GPS which takes the help of network towers and WI-FI hot spots to quickly determine the location nearby and help the Android GPS enabled smartphone to get a lock with GPS satellites.Android smartphones with AGPS chips can also have a lock with GPS satellites without the need of data plan or network but require clear sky view and some time to have a lock with GPS satellites.

Google Maps is a navigation system with maps which load on having an active data connection and usually locate your device position with the help of network tower or WI-FI hot spots in which location is not that accurate.To have a accurate position in Android there are two settings in My Locations one is to enable Use wireless networks which is bit calculative and other is Use GPS satellites which requires more battery plus clear view of sky.So we can say AGPS chips enabled or equipped Android smartphone have the accurate location position and use GPS satellites to the fullest.

GeoCode

Geocoding is the process of transforming a street address or other description of a location into a (latitude, longitude) coordinate.

Following links will help you to learn

1) https://developers.google.com/maps/documentation/directions/
2) http://blog.synyx.de/2010/06/routing-driving-directions-on-android-part-1-get-the-route/
3) http://eagle.phys.utk.edu/guidry/android/mappingDemo.html
4) Google Maps API Version difference

Community
  • 1
  • 1
Chintan Rathod
  • 25,864
  • 13
  • 83
  • 93
1

Take a Look at This, It might help you,

LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener mlocListener = new MyLocationListener();

mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
    mlocListener);


public class MyLocationListener implements LocationListener {

@Override
public void onLocationChanged(Location loc) {
loc.getLatitude();
loc.getLongitude();

Geocoder gcd = new Geocoder(getApplicationContext(),
        Locale.getDefault());
try {
    mAddresses = gcd.getFromLocation(loc.getLatitude(),
            loc.getLongitude(), 1);

} catch (IOException e) {

}

String cityName = (mAddresses != null) ? mAddresses.get(0)
        .getLocality() : TimeZone.getDefault().getID();
String countryName = (mAddresses != null) ? mAddresses.get(0)
        .getCountryName() : Locale.getDefault().getDisplayCountry()
        .toString();


       mCurrentSpeed.setText(loc.getSpeed());
   }

   @Override
   public void onProviderDisabled(String provider) {
    Toast.makeText(getApplicationContext(), "Gps Disabled",
          Toast.LENGTH_SHORT).show();
   }

   @Override
   public void onProviderEnabled(String provider) {
      Toast.makeText(getApplicationContext(), "Gps Enabled",
        Toast.LENGTH_SHORT).show();
   }

   @Override
   public void onStatusChanged(String provider, int status, Bundle extras) {
   }
 }
RajeshVijayakumar
  • 10,281
  • 11
  • 57
  • 84