2014-05-15 26 views
2

我有一個Android應用程序,它使用.so文件,.so根據手機連接的網絡更改其行爲,即如果連接到AT&T,您需要執行XYZ。如果你在Verizon上工作,那麼你做ABC,否則你做XY如何區分Android應用程序中的移動運營商?

  1. 有沒有什麼好的辦法來區分移動網絡?
  2. 我以爲用某種方式使用PLMN,請問有沒有強大的方法可以做 那? (我希望它在漫遊時也能工作等)。

我見過this,但我需要做的是隻有在沒有包裝或Java參與的C代碼,這意味着不能使用下列內容:

TelephonyManager telephonyManager =((TelephonyManager) Context.getSystemService(Context.TELEPHONY_SERVICE)); 
String operatorName = telephonyManager.getNetworkOperatorName(); 
+0

當你說你希望它能夠工作漫遊時,你的意思是漫遊時,你想要家庭網絡的行爲,還是你想要當前網絡的行爲? –

+0

@SList,我想要了解當前網絡的行爲,否則我會用SIM來區分。 – 0x90

回答

2

你可以得到當前與AT+COPS?命令一起使用PLMN。從27.007

+COPS?        +COPS: <mode>[,<format>,<oper>[,<AcT>]] 

...

Read command returns the current mode, the currently selected operator and the 
current Access Technology. If no operator is selected, <format>, <oper> and <AcT> 
are omitted. 

....

<oper>: string type; <format> indicates if the format is alphanumeric or numeric; 
long alphanumeric format can be upto 16 characters long and short format up to 8 
characters (refer GSM MoU SE.13 [9]); numeric format is the GSM Location Area 
Identification number (refer 3GPP TS 24.008 [8] subclause 10.5.1.3) which 
consists of a three BCD digit country code coded as in ITU-T E.212 Annex A 
[10], plus a two BCD digit network code, which is administration specific; 
returned <oper> shall not be in BCD format, but in IRA characters converted from 
BCD; hence the number has structure: (country code digit 3)(country code digit 2) 
(country code digit 1) (network code digit 3)(network code digit 2)(network code 
digit 1) 
+0

謝謝,順便說一句,有沒有什麼辦法可以在無根Android手機上運行Java命令? – 0x90

+0

我還沒有測試過自己,但據我所知調制解調器設備文件應該可以訪問(通過adb),而不需要根植電話。當從命令行與調制解調器交互時,我推薦我的程序[atinout](http://atinout.sourceforge.net/)。 – hlovdal

0

使用以下兩種at命令(see also

AT+COPN   7.21   - Read operator names 
AT+COPS   7.3    - PLMN selection