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 ?
Asked
Active
Viewed 1,641 times
2 Answers
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
-
Yes. I want to Get Location Name Like Jaipur,Delhi etc. – user1722589 Oct 06 '12 at 06:05
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
-
Thanks Amit .But Actully i want to get location name like Jaipur,Delhi etc. – user1722589 Oct 06 '12 at 06:07
-
i used it .when i am printing toast notification it showing service not available. – user1722589 Oct 06 '12 at 06:28
-
-
also check http://stackoverflow.com/questions/5205650/geocoder-getfromlocation-throws-ioexception-on-android-emulator – Amit Hooda Oct 06 '12 at 06:33