前段时间, 一个外单项目的需要,查看了下这方面代码,修改的地方很小,主要通过TelephonyManager中类的getNetworkOperatorName()方法获得网络运营商名称
在Phone\src\com\android\phone\MsmsDialerActivity下面,找到protected Dialog onCreateDialog方法
修改前:
Button[] callButton = new Button[mPhoneCount];
int[] callMark = {
R.id.callmark1, R.id.callmark2
};
int[] subString = {
R.string.sub_1, R.string.sub_2
};
boolean[] subActive = {
mSub1IsActive, mSub2IsActive
};
int index = 0;
for (index = 0; index < mPhoneCount; index++) {
callButton[index] = (Button) layout.findViewById(callMark[index]);
callButton[index].setEnabled(subActive[index]);
callButton[index].setText(getString(subString[index])); //sim1、sim2
callButton[index].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dismissDialog(CHOOSE_SIM_DIALOG);
switch (v.getId()) {
case R.id.callmark1:
startOutgoingCall(MsmsConstants.SUB1, false);
break;
case R.id.callmark2:
startOutgoingCall(MsmsConstants.SUB2, false);
break;
}
}
});
}
break;
修改后:
Button[] callButton = new Button[mPhoneCount];
int[] callMark = {
R.id.callmark1, R.id.callmark2
};
int[] subString = {
R.string.sub_1, R.string.sub_2
};
boolean[] subActive = {
mSub1IsActive, mSub2IsActive
};
int index = 0;
for (index = 0; index < mPhoneCount; index++) {
callButton[index] = (Button) layout.findViewById(callMark[index]);
callButton[index].setEnabled(subActive[index]);
//start modify by yang 2012-10-25
// callButton[index].setText(getString(subString[index]));
{
TelephonyManager tm=(TelephonyManager)getBaseContext().getSystemService(
PhoneFactory.getServiceName(Context.TELEPHONY_SERVICE,index));
if (tm.hasIccCard()&&(tm.getNetworkOperatorName() != null)
&& tm.getSimState()==TelephonyManager.SIM_STATE_READY){
if(tm.getNetworkOperatorName().equals("")){
callButton[index].setText(com.android.internal.R.string.lockscreen_carrier_default);
}
else{
callButton[index].setText(tm.getNetworkOperatorName());
}
}
else{
callButton[index].setText(getString(subString[index]));
}
}
//end modify
callButton[index].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dismissDialog(CHOOSE_SIM_DIALOG);
switch (v.getId()) {
case R.id.callmark1:
startOutgoingCall(MsmsConstants.SUB1, false);
break;
case R.id.callmark2:
startOutgoingCall(MsmsConstants.SUB2, false);
break;
}
}
});
}
break;
有兴趣的可以试下