2016-12-07 25 views
0
TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); 

if(tm != null) 
    carrier = tm.getNetworkOperatorName(); 

我只是想获得网络运营商的名称,被称为'载体'。 但总是返回“”与Android 6设备。有没有解决方法?我怎样才能得到getNetworkOperatorName()与Android 6.x

+0

见注释这里http://stackoverflow.com/questions/3838602/how-to-find-out-carriers-name-in-android#comment19751066_3838947 –

+0

什么的Android设备6?模拟器?在模拟器中没有载体,可能 –

+0

<使用权限android:name =“android.permission.READ_PHONE_STATE”/>是否存在此权限或不在您的代码中 – Piyush

回答

1
//Here is snippet, hope it helps you! 
TelephonyManager tManager = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE); 

// Get carrier name (Network Operator Name) 
String carrierName = tManager.getNetworkOperatorName(); 
String operatorName = tManager.getSimOperatorName(); //try this 

// Get Phone model and manufacturer name 
String manufacturer = Build.MANUFACTURER; 
String model = Build.MODEL; 
+0

getCarrierName() – Raman

+0

非常感谢! –