Question

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?

Was it helpful?

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 :)

OTHER TIPS

As a continuation to my comment, you could go by those lines of filtering users by country code.

The problem - only some carriers store the phone number on the actual SIM card. If so, you will be able to obtain it using

 TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
    String mPhoneNumber = tMgr.getLine1Number();

To avoid the instances of those carriers who don't store the actual number on the SIM - there is no way to retrieve the number seeing it is not stored on the phone. So, what I would do, is simply on the first run of application, request the user to input his full phone number (including country code) - and store that in SharedPrefs. Then, you will know if to run the app or not.

Good luck, hope this has helped!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top