Android run different functions depend on country
Вопрос
I want to run different functions to my app depending of the country of the user For example if Country is US then do this if country is UK then do this
....could someone help me? Thank you in advance
Решение
You can use different approaches:
String locale = context.getResources().getConfiguration().locale.getCountry();
gets the country according to the phone settings (this can be changed by the user), whereas
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String countryCode = tm.getSimCountryIso();
gets the country of the sim card (can not be changed by the user)
So you have the choice what fits your needs best
Другие советы
Use Locale.getDefault()
to get the current user's Locale, and do whatever you like from the language code and country code that you get from that.
Не связан с StackOverflow