gkaykck
gkaykck

Reputation: 2367

How to get City and Country of a user in android without GPS?

How to get a users City and Country from an application in Android without GPS?

Upvotes: 4

Views: 8279

Answers (6)

Jacques Giraudel
Jacques Giraudel

Reputation: 512

You can also use the IP address, there is some webservices which will give you the location of the caller : http://free-web-services.com/web-services/geo/ip-to-location/

Upvotes: 0

Ben H
Ben H

Reputation: 3905

another solution would be to use a web service that detects the user's location via IP address.

http://ipinfodb.com/ip_location_api_json.php

Upvotes: 0

ferostar
ferostar

Reputation: 7082

From a thread in the mailing list:

  • You could use the phone number which is assigned to you. The phone number starts with the country code.
  • Also the IMEI has information about in which country your phone was approved/registered.

"If you try to get information to which MNC-MCC you are connected use the TelephonyManager.getNetworkOperator() API. The MCC (mobile country code) is the information you are looking for."

Apparently, the simplest of all getLocale().getDisplayCountry() doesn't works at all so, without the location API, this is all you can do (besides Wi-Fi location).

Upvotes: 2

Peter Knego
Peter Knego

Reputation: 80340

Get users location via LocationManager.NETWORK_PROVIDER. Then use Geocoder to get address from location.

Upvotes: 0

Maxim
Maxim

Reputation: 3006

You can do it throug Cell tower or WiFi location. Or through PassiveLocation Provider. You can learn about it in this Google I/O video (min 20) http://developer.android.com/videos/index.html#v=twmuBbC_oB8

Upvotes: 3

user432209
user432209

Reputation: 20167

Pop up a dialog and ask them to enter a zip code?

Where else exactly would this "data" come from if not GPS?

Upvotes: -2

Related Questions