0

In my application I want to use the users' current latitude and longitude. I use the following example.

Still I did not get the answer.

Can emulator displays the latitude and longitude?

How shall i get latitude and longitude from the IP address??

quick response will help me a lot.

Community
  • 1
  • 1
Dray
  • 1,904
  • 5
  • 27
  • 42
  • As stated, this is a duplicate of [How to get Latitude and Longitude of the mobiledevice in android?](http://stackoverflow.com/questions/2227292/how-to-get-latitude-and-longitude-of-the-mobiledevice-in-android). Let us know what you tried and what's going wrong, and note that the location service doesn't get the location from your IP address. – Andrew Aylett Apr 10 '12 at 09:44
  • The example u have mentioned above doesnt give the answer for me in the device. is there any other way to get latitude and longitude from mobile device?not from Ip adress? – Dray Apr 10 '12 at 09:55
  • @Dray by using the GPS-module. See my answer... – Lukas Knuth Apr 10 '12 at 10:28

5 Answers5

2

There are some different APIs you can use to get a IPs location. This post mentions a few.

Community
  • 1
  • 1
Heinrisch
  • 5,835
  • 4
  • 33
  • 43
2

Your linked answer uses GPS to get the current position. The Emulator does not have a working GPS-module, so when testing this in the emulator, you can add fake-data for the lat. and long. so you can test the code. More here: How to emulate GPS location in the Android Emulator?

If you want to get a location on an IP-address, you can use certain services for that. This has already been discussed here: What's the simplest way to get a user's latitude and longitude from an ip address

As mentioned in the linked post, I'm not sure about the accuracy of those services.

Community
  • 1
  • 1
Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111
2

I dont think there is a possibility to return position data from an IP adress possibly the country but not pin point exact (altitude, longtitude) therefor you need to return device gps data wich is transfered though the internet but has nothing to do with an IP adress..

dennis
  • 2,000
  • 18
  • 26
0

I have finally found my mistake. the example given HERE works fine. And the mistake was mine. In the location Setting in my mobile, i forget to check the mobile networks option. once i checked tat option i got the latitude and longitude for my current location.

Community
  • 1
  • 1
Dray
  • 1,904
  • 5
  • 27
  • 42
0

Try http://www.iptolatlng.com/ , it provides JSON and JSONP results

mikewhit
  • 121
  • 5