1

I need to customize my Android application's UI based on the SIM operator that is inserted in my phone. For example, If I insert airtel, I need to get yellow UI with yellow launcher icon. For Vodafone I need to get purple UI with purple launcher icon.

Is it possible to point to different resource folder based on the operator in my phone? or How else to customize the theme? How else to achieve this?

Ajitha
  • 717
  • 1
  • 7
  • 30
  • have a look here on how to the get the carrier name -- http://stackoverflow.com/questions/29938430/how-to-detect-network-operators-programmatically-on-android – Tasos Jan 20 '16 at 07:10
  • have a look at this [post](http://androidexample.com/How_to_get_SIM_details_in_android/question_answer.php?view=qad&token=33) – Iamat8 Jan 20 '16 at 07:11

3 Answers3

3

Yes, It's simply possible!

  • First create multiple layout xml files (for each operator).

  • Then determine which operator you're using.

    TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    String opName = telephonyManager.getNetworkOperatorName();
    
  • Now, apply the layout based on the name of operator.

    if(opName.equals("vodafone")){
          setContentView(R.layout.vodafone_layout);
    }
    

Using the approach discussed above, you can have multiple (potentially different layout structure and widgets per operator) layouts for each operator. If you want to only change theme for each operator a better way would be using setTheme() before calling setContentView().

frogatto
  • 28,539
  • 11
  • 83
  • 129
  • @Ajitha http://stackoverflow.com/questions/1103027/how-to-change-an-application-icon-programmatically-in-android – frogatto Jan 20 '16 at 07:31
  • The above link changes only the shortcut icon and not the appdrawer icon in the application tray :( – Ajitha Jan 20 '16 at 11:09
2

You can get carrier's name by using following code

    TelephonyManager manager = (TelephonyManager) 
getSystemService(Context.TELEPHONY_SERVICE);

String carrierName = manager.getNetworkOperatorName();

And once you have the name you can compare the string with predefined name string and then change color accordingly

Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84
1

https://developer.android.com/guide/topics/resources/providing-resources#AlternativeResources Can use mcc mnc combination with layout folder to specify region specific and operator specific customization for layout files.

Niru
  • 153
  • 1
  • 8