- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我从 sdk 级别 android.os.Build.VERSION_CODES.LOLLIPOP_MR1 知道我们得到 subscriptionInfoList 作为 subscriptionManager.getActiveSubscriptionInfoList();通过使用它,我们将识别所有支持的 SIM 卡信息。
我需要在 android 较低版本中获得相同的内容。任何人都可以帮助我吗?
最佳答案
幸运的是,有几种 native 解决方案。
对于 API >=17:
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
// Get information about all radio modules on device board
// and check what you need by calling #getCellIdentity.
final List<CellInfo> allCellInfo = manager.getAllCellInfo();
for (CellInfo cellInfo : allCellInfo) {
if (cellInfo instanceof CellInfoGsm) {
CellIdentityGsm cellIdentity = ((CellInfoGsm) cellInfo).getCellIdentity();
//TODO Use cellIdentity to check MCC/MNC code, for instance.
} else if (cellInfo instanceof CellInfoWcdma) {
CellIdentityWcdma cellIdentity = ((CellInfoWcdma) cellInfo).getCellIdentity();
} else if (cellInfo instanceof CellInfoLte) {
CellIdentityLte cellIdentity = ((CellInfoLte) cellInfo).getCellIdentity();
} else if (cellInfo instanceof CellInfoCdma) {
CellIdentityCdma cellIdentity = ((CellInfoCdma) cellInfo).getCellIdentity();
}
}
在AndroidManifest中添加权限:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>
要获得网络运营商,您可以检查 mcc 和 mnc 代码:
对于最新的设备,您可以使用最新的 API。
对于 API >=22:
final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
final List<SubscriptionInfo> activeSubscriptionInfoList = subscriptionManager.getActiveSubscriptionInfoList();
for (SubscriptionInfo subscriptionInfo : activeSubscriptionInfoList) {
final CharSequence carrierName = subscriptionInfo.getCarrierName();
final CharSequence displayName = subscriptionInfo.getDisplayName();
final int mcc = subscriptionInfo.getMcc();
final int mnc = subscriptionInfo.getMnc();
final String subscriptionInfoNumber = subscriptionInfo.getNumber();
}
对于 API >=23。只检查手机是否是双卡/三卡/多卡:
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (manager.getPhoneCount() == 2) {
// Dual sim
}
关于android - 如何识别 sdk 级别低于 android.os.Build.VERSION_CODES.LOLLIPOP_MR1 的双卡运营商名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40373191/
这个问题已经存在: 关闭 13 年前。 Possible Duplicate: What is the !! (not not) operator in JavaScript? 我见过运算符 ! 像
我最近正在读《行动中的格鲁夫》。在第7章中,它介绍了*。运算符(operator) 。当我运行有关此运算符的代码时,我会遇到一些错误。 class Invoice {
我在沙箱 Groovy 上工作,我想阻止 .@ 运算符。我正在使用 SecureASTCustomizer 并编写了一个自定义的 SecureASTCustomizer.ExpressionCheck
我有一个函数接受一个包含大量数据的数组,例如,其中一个数据是“name”:$data = ['name' => 'John'] ; 现在,如果我想使用默认值从中获取名称,我有两个经常使用的选项。 $n
我只是想知道这是否是 C89 程序的“好”代码。 obj_ptr = (obj*) (ptr1 || ptr2); 本质上,如果 ptr1 != NULL 和 ptr2,它的作用(至少在我的计算机上的
我定义了一个类 User,并覆盖了它的 == 运算符,如下所示: class User attr_reader :age def initialize age @age = age
这个问题在这里已经有了答案: Why does "++x || ++y && ++z" calculate "++x" first, even though operator "&&" has hi
pipe(|) 和output(>) 重定向运算符有什么区别?我可以在哪里使用它们? 例如: 我通常只在 grep 中使用管道 (|) find . | grep abc 我遇到的输入输出重定向的唯一
我正在为此代码使用 g++ 10.2。有谁知道为什么我在最后一次 std::views::reverse 中收到编译器错误?在 results3 ? #include #include int m
假设我们正在使用 MASM 6.1/16 位/大数据模型编写汇编代码,并且我们有一个名为 MY_VAR 的变量(标签)、一个名为 MY_SEG 的段和一个名为 MY_GROUP 的段组。假设 MY_V
我试图在基类中使用宇宙飞船运算符,所以我将通过编译器定义所有运算符。 (来源:https://devblogs.microsoft.com/cppblog/simplify-your-code-wit
我在某处看到这段代码片段: var idx = SOME_VALUE; var color = { yellor: 1, red: 2, black: 0 }; var x = color
我观察到在某个时候有一个 ?海湾合作委员会的运营商。我如何在 GCC 4.5 下使用它们?它们是否已被移除,如果是,何时移除? Offset block_count = (cpfs->geo.bloc
我不是每天都阅读 C#,而是正在阅读最近的提交,其中包含一些让我感到困惑的内容: if (( length > maxLength) && ! IsTable(furniture.FurnitureT
拥有 public void Main() { int i = 0; Console.WriteLine($"I was {i++}, now I is {i}"); bool b = t
我观察到在某个时候有一个 ?海湾合作委员会的运营商。我如何在 GCC 4.5 下使用它们?它们是否已被移除,如果是,何时移除? Offset block_count = (cpfs->geo.bloc
今天,我听说了 Karatsuba 算法,一种快速乘法算法。我很好奇这个“快”是什么意思? 通常,我们在计算一段代码的时间复杂度时,会考虑使用 * 运算符作为 O(1) 的乘法运算,如果它始终为真,那
我观察到在某个时候有一个 ?海湾合作委员会的运营商。我如何在 GCC 4.5 下使用它们?它们是否已被移除,如果是,何时移除? Offset block_count = (cpfs->geo.bloc
我正在学习 Angular 和 RxJS 运算符。我正在使用 Hearthstone API 来训练它。我究竟做错了什么 ?我想过滤流以仅返回“萨满”卡。我知道,Api 让我有机会按类(class)获
正如标题所说,我正在尝试通过 += 运算符将文本附加到隐式解包的可选字符串,这给了我 'String!' is not identical to 'UInt8' 让你明白我的意思: var myStr
我是一名优秀的程序员,十分优秀!