【问题标题】:How to differentiate between cellular operators in an Android application?如何区分 Android 应用程序中的蜂窝运营商?
【发布时间】:2014-07-03 08:28:29
【问题描述】:

我有一个使用.so 文件的Android 应用程序,.so 根据手机连接的网络改变他的行为,即如果你连接到AT&T,你需要做XYZ。如果你在Verizon 上工作,你就在ABC 上工作,否则你在XY 上工作。

  1. 有什么好的方法可以区分移动网络吗?
  2. 我想以某种方式使用PLMN,有什么可靠的方法吗 那? (我希望它在漫游时也能工作等)。

我见过this,但我只需要在没有包装器或 Java 参与的 C 代码中执行此操作,这意味着无法使用以下内容:

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

【问题讨论】:

  • 当你说你希望它在漫游时工作,你的意思是在漫游时你想要家庭网络的行为,还是你想要当前网络的行为?
  • @SList,我想要当前网络的行为,否则我会通过 SIM 来区分。

标签: android c mobile at-command cellular-network


【解决方案1】:

您可以通过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)

【讨论】:

  • 谢谢,顺便说一句,有没有办法在无根的 Android 手机上运行 Java 上的命令?
  • 我还没有测试过自己,但据我所知,调制解调器设备文件应该可以访问(通过 adb),而无需 root 手机。从命令行与调制解调器交互时,我推荐我的程序atinout
【解决方案2】:

使用以下两个at 命令(see also

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多