1

I'm working on Android application. In this, I need that when I capture image or selects from gallery for uploading, it should show current location like city etc. I've tried using GPS but when I run it on Android Emulator, it shows Latitude and Longitude with 0 ,0 . Any help will be appreciated. What should I do for this ?

user1722589
  • 11
  • 1
  • 4

2 Answers2

0

Obviously you can not fetch GPS in emulator. Emulator is not an real device. You can use .gpx files which contains lal-lon details. You need to upload this file from DDMS when your program is running, so you can fetch dummy GPS Co-ordinates in emulator.

You can find sample .gpx from google

Lucifer
  • 29,392
  • 25
  • 90
  • 143
0

You can not fetch GPS in emulator.But there is a work around for that

telnet localhost 5554

Connect to your emulator.Like shown above and then

geo fix -23.234334 32.234344 4392

First two are longitude and latitude values and the last one is altitude in meters.

Now from there you can call from GeoCoder http://developer.android.com/reference/android/location/Geocoder.html

 public List<Address> getFromLocation (double latitude, double longitude, int maxResults)

It will return a list of Address that has a method getLocality

Geocoder gcd = new Geocoder(context, Locale.getDefault());
List<Address> addresses = gcd.getFromLocation(lat, lng, 1);
if (addresses.size() > 0) 
    Log.i("address",""+addresses.get(0).getLocality());

Try with various values and check!

Amit Hooda
  • 2,133
  • 3
  • 23
  • 37