Search code examples
androidregionrestriction

Restrict android application to specific region


I want my application to work in specific region e.g US.

We can limit distribution of application from play market but i found there are some hacks to install those apps.

I have to somehow limit the use within application.

For that I can retrieve user's GPS location and use Google's Geocode API for first run. But what if user travels to some other region?

I will have to use Location change listener to cater this scenario, but this will drain battery.

If I go for device's timezone, User can change it.

Is there any other thing i can possibly do to restrict application to specific region?


Solution

  • You can also check for the network the user is registered on with TelephonyManager

    You have 2 methods that can be helpful.

    GetNetworkCountryIso

    http://developer.android.com/reference/android/telephony/TelephonyManager.html#getNetworkCountryIso()

    and

    GetSimCountryIso

    http://developer.android.com/reference/android/telephony/TelephonyManager.html#getSimCountryIso()


    Explanation


    getNetworkCountryIso() will give you the iso for the country which the user is currenty registered for.
    ie: If you're from Albania (al) and went to travel to USA (us) this will return "us"

    getSimCountryIso() will give you the iso for the country where the SIM provider's country code..
    ie: If you're from Albania (al) and went to travel to USA (us) this will return "al"

    UPDATE

    You can integrate (if server side available) http://www.whois.net/ip-address-lookup/ to look for the device IP address. You can get the IP like this.

    How to get IP address of the device from code?

    With a combination of all this functions (Wifi, network provider, IP, GPS, Google Play regions) you can reduce a lot the use limitations of your app. In the other hand if the user it´s advance enough to fake the IP using a proxy, doesn't turn on the Wifi / GPS and doesn't have SIM card, there´s not much more to do.


    Hope it helps :)