2016-12-07 51 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

非常感謝! –