我正在构建一个android应用程序,其中我需要一个值"getSimOperator“。
我可以得到这个值> 21 API版本,但对于较低版本的双SIM卡。我正在获取SIM1的值,但无法获取SIM2的值。
如何获取SIM2 < 21接口版本的getSimOperator值。
我早些时候发布了一个问题,下面是How to get Mcc and Mnc below LOLLIPOP_MR1的链接。
有人给我推荐了一个链接dual sim android phone which sim receive a call。
但我得到一个错误时,实现上述链接的代码。我列出了错误"java.lang.NoSuchMethodException: getDefault int“
Cloud任何人都可以向我解释为什么会出现这个错误。
发布于 2016-12-05 19:52:22
此处的链接可能会对您有所帮助,并参考本示例http://www.programcreek.com/java-api-examples/android.telephony.TelephonyManager中的第24号示例
试试这个Github链接。https://github.com/illarionov/MozStumbler/blob/develop/src/org/mozilla/mozstumbler/cellscanner/GeminiCellScanner.java
在以下方法中,返回可用simcard的所有信息。
private List<CellInfo> getCellInfo(int presentSimNumsIndex){}另一种方法也是如下所示。对于>=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代码:
https://stackoverflow.com/questions/40972937
复制相似问题