Dray
Dray

Reputation: 1954

How to get Latitude and Longitude from mobile device Android

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.

Upvotes: 0

Views: 3601

Answers (5)

mikewhit
mikewhit

Reputation: 121

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

Upvotes: 0

Dray
Dray

Reputation: 1954

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.

Upvotes: 0

dennis
dennis

Reputation: 2020

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..

Upvotes: 2

Lukas Knuth
Lukas Knuth

Reputation: 25755

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.

Upvotes: 2

Heinrisch
Heinrisch

Reputation: 5935

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

Upvotes: 2

Related Questions