我有一个Android应用程序,它使用一个.so
文件,.so
根据手机连接到的网络改变他的行为,也就是说,如果你连接到AT&T
你需要做XYZ
如果你在Verizon
上工作,你就在ABC
上工作,否则你就在XY
上工作。
有没有什么好的方法来区分移动网络?
我想在某种程度上使用PLMN有什么好办法
那?(我希望它也能在漫游时工作等)。
我看到过this,但我只需要在没有包装器或Java约定的C代码中执行,这意味着不能使用以下代码:
TelephonyManager telephonyManager =((TelephonyManager) Context.getSystemService(Context.TELEPHONY_SERVICE));
String operatorName = telephonyManager.getNetworkOperatorName();
最佳答案
您可以使用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)