-1

I got the Latitude and longitude values in Emulator using Telnet.(i.e) GPS.

I have a doubt (i.e) without google map can we able to get the current location using the latitude and longitude.

Android Boy
  • 4,335
  • 6
  • 30
  • 58
chocolate boy
  • 63
  • 1
  • 6
  • 1
    @BB Expert: That is completely wrong. There is no connection between knowing one's current latitude and longitude and being able to display it on a map. – NickT May 25 '12 at 07:42
  • @BB Expert: We can fetch the location using locationManager without using google map. – Android Boy May 25 '12 at 07:44
  • 1
    This kind of question asked many times, you should search before posting a question. @cholocateboy – Lucifer May 25 '12 at 07:46
  • possible duplicate of [Latitude and Longitude of the current location](http://stackoverflow.com/questions/3862731/latitude-and-longitude-of-the-current-location) – Tim May 25 '12 at 07:56

2 Answers2

0

You can fetch the current location using GPS and Google map both. If you want to fetch location through Google map then plz show this tutorial. And you can see this previous asked question.

If you want to fetch location without Google map then you can be use location manager.

To do this, we need to add the fallowing code in the OnCreate method:

/* Use the LocationManager class to obtain GPS locations */
LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
LocationListener mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);

In the custom class MyLocationListener using implements the interface LocationListener.

We will add our own personal Location listener, so we can override some of the functions to do what we want. In our case we will just print a message to the screen in the fallowing cases:

onLocationChanged ( Location Update )
onProviderDisabled ( GPS Off )
onProviderEnabled (GPS On )

And add another mandatory method, which will do nothing.

onStatusChanged (We are not adding nothing here).

After that give the permission in AndroidManifest.xml file:

android:name="android.permission.ACCESS_FINE_LOCATION"
Community
  • 1
  • 1
Android Boy
  • 4,335
  • 6
  • 30
  • 58
0

You can get latitude and longitude by this code

GPS_Location mGPS = new GPS_Location(MyApplication.getAppContext());

if (mGPS.canGetLocation) {

    mLat = mGPS.getLatitude();
    mLong = mGPS.getLongitude();

} else {
    System.out.println("cannot find");
}

you must add the gps permissions and other permissions to your app

Pang
  • 9,564
  • 146
  • 81
  • 122
Ribin Das
  • 63
  • 1
  • 2