使用 Android 应用程序访问 SIM 卡?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2372757/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Access the SIM Card with an Android Application?
提问by Adrien
I wonder if it's possible to access to the SIM card with an Android Application
我想知道是否可以通过 Android 应用程序访问 SIM 卡
回答by Hubert
You can get the IMEI like this (but is it what you want ?), just an exemple :
您可以像这样获得 IMEI(但这是您想要的吗?),只是一个例子:
mTelephonyMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String imei = mTelephonyMgr.getDeviceId();
Likewise, you have
同样,你有
String getSimCountryIso():
Returns the ISO country code equivalent for the SIM provider's country code.
返回与 SIM 提供商的国家/地区代码等效的 ISO 国家/地区代码。
String getSimOperator():
Returns the MCC+MNC (mobile country code + mobile network code) of the provider of the SIM.
String getSimOperator():
返回 SIM 卡提供商的 MCC+MNC(移动国家代码 + 移动网络代码)。
String getSimOperatorName():
Returns the Service Provider Name (SPN).
String getSimOperatorName():
返回服务提供商名称 (SPN)。
String getSimSerialNumber():
Returns the serial number of the SIM, if applicable.
String getSimSerialNumber():
返回 SIM 的序列号(如果适用)。
int getSimState():
Returns a constant indicating the state of the device SIM card.
int getSimState():
返回一个常量,指示设备 SIM 卡的状态。
String getSubscriberId():
Returns the unique subscriber ID, for example, the IMSI for a GSM phone.
String getSubscriberId():
返回唯一的用户 ID,例如,GSM 电话的 IMSI。
For more, take a look at this page
有关更多信息,请查看此页面
and don't forget to add the correct permission in the manifest (getDeviceId() => Requires Permission: READ_PHONE_STATE
)
并且不要忘记在清单中添加正确的权限 ( getDeviceId() => Requires Permission: READ_PHONE_STATE
)
回答by Rahul
Without SmartCardAPI from SEEK(Secure Element Evaluation Kit) its never possible. In majority Android phones available in market SmartCardAPI is not implemented. So either you build your own Android after integrating the SmartCardAPI code or wait for some decent phone with this feature to come out. You can find the patch file for implementation here.
如果没有 SEEK(安全元件评估套件)的 SmartCardAPI,它永远不可能。在市场上可用的大多数 Android 手机中,未实现 SmartCardAPI。因此,要么在集成 SmartCardAPI 代码后构建自己的 Android,要么等待一些具有此功能的不错的手机问世。您可以在此处找到用于实施的补丁文件。
回答by skoetel
SmartCard API for Android might be of interest for you: http://code.google.com/p/seek-for-android/
您可能对 Android 智能卡 API 感兴趣:http: //code.google.com/p/seek-for-android/
回答by Robert
SIM card access is only possible for system applications:
SIM 卡访问仅适用于系统应用程序:
Low level access to the SIM card is not available to third-party apps. The OS handles all communications with the SIM card including access to personal information (contacts) on the SIM card memory. Applications also cannot access AT commands, as these are managed exclusively by the Radio Interface Layer (RIL). The RIL provides no high level APIs for these commands.
第三方应用程序无法对 SIM 卡进行低级别访问。操作系统处理与 SIM 卡的所有通信,包括访问 SIM 卡存储器中的个人信息(联系人)。应用程序也无法访问 AT 命令,因为这些命令由无线电接口层 (RIL) 专门管理。RIL 没有为这些命令提供高级 API。
source: https://source.android.com/security/overview/app-security.html#sim-card-access
来源:https: //source.android.com/security/overview/app-security.html#sim-card-access
回答by Zichen Liang
SEEK is most useful one,but majority Android phones are not support that.So,maybe we can assess SIM card by some other method like read SMS(in SIM card).
SEEK是最有用的一个,但大多数Android手机不支持。所以,也许我们可以通过一些其他方法来评估SIM卡,比如读取短信(在SIM卡中)。
回答by ofskyMohsen
You should use IccFileHandler in interal api of android using java reflection . It is located at framework/base/telephony
您应该使用 java 反射在 android 的内部 api 中使用 IccFileHandler 。它位于框架/基础/电话