Android Localisations with Mobile country code

Egbai Smile Mmumene
AndroidPub
Published in
2 min readJan 25, 2018

When doing localisations for apps we have a couple of options which include

  1. Screen size
  2. Language
  3. Mobile Country Code

The most common one’s ever used are Screen size(dp/sw) & Language(en,fr, etc), while Mobile Country Code can be a very efficient way to select resources based on what country the user is in. This allows you to tailor features to your users countries. Here’s a link to the android resource on localisation, there specifies a table which shows how resources are selected based on precedence.

According to the table above you can see that android takes the MCC(Mobile country code) & MNC(Mobile network code) into consideration first in resource selection before it takes other parameters into consideration.

Now you may be asking why you should consider using mcc or mnc when you can already use screen density pixels(dp) and region to define resources. Well using the mcc code allows you to target a particular resource or even feature(build flavours) by country since a countries mcc is unique to it. For me this just helps me with an easier way to segregate my resources and image drawables, incase am using an image that might be offensive in a particular country or I need to display various currency symbols, the possibilities are endless. Combining mcc and resource alias is a very beautiful way of segmenting your ui resources.

If for any reason you need to access the current mcc of a country you can easily do so using the TelephonyManager

TelephonyManager telephonyManager = (TelephonyManager) App.getInstance().getSystemService(Context.TELEPHONY_SERVICE); //gets the country mcc code                                    String countryISO = telephonyManager.getNetworkCountryIso();/*gets the mcc appended with the mnc. Note that mcc is always the first 3 digits returned with this method so to get the mnc you can just split the String or get the chars from the 3rd index to the last.*/String countryMnc = telephonyManager.getNetworkOperator(); 

--

--

Egbai Smile Mmumene
AndroidPub

technology lover, mobile developer, travel enthusiast