how do you get the phone's MCC and MNC in Android?

前端 未结 7 1043
感情败类
感情败类 2020-12-04 11:18

The only way I\'ve found of retrieving MCC and MNC is by overriding an activity\'s onConfigurationChanged method, as such:

public void onConfigurationChanged         


        
7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 11:57

    You do know there are two MCC/MNC's for an active phone? (One is the country code and carrier id for the Sim card, the other is for the network/cell tower in use.)

    If the getResources().getConfiguration().mcc is not empty in airplane mode, it's the Sim value TelephonyManager.getSimOperator(), not the tower value TelephonyManager.getNetworkOperator().

    I don't know which the OP wants, but Answer 3 will give him different results than his original code if the getConfiguration is really the Sim values.

提交回复
热议问题