0

It is easy to get the country when you are online. But is it also possible to get the country where the phone is in right now, without an internet connection?

kevingoos
  • 3,785
  • 4
  • 36
  • 63

2 Answers2

1

No, you must have a network connection to get country info. All of the options for you to poll, such as Telephony, GPS, Geocoder, Wi-fi, etc, all require some sort of network connection.

Edit: Yes you can get GPS coordinates without an internet connection, but to turn those into anything useful (such as a country name, as you requested) you would need to send the coords to some sort of lookup service via an internet connection (such as Android's Geocoder class). The only other possible way to get the country name would be if you had pre-installed a set of addresses that you knew you were going to look up directly on to the device.

NoChinDeluxe
  • 3,446
  • 1
  • 16
  • 29
1

You don't need an internet connection to use GPS. GPS information is provided by satellites up in space.

How do I get the current GPS location programmatically in Android?

To figure out the country, use an offline reverse geocoder, such as https://github.com/AReallyGoodName/OfflineReverseGeocode

Or, get the shape files of countries and see if your GPS co-ordinates are inside the shape. See http://www.gadm.org/ and http://www.naturalearthdata.com/

Neil McGuigan
  • 46,580
  • 12
  • 123
  • 152