我正在使用 PhoneGap 开发跨平台移动应用程序,我需要检索 IMSI 代码。
问题来了:有没有办法通过PhoneGap做到这一点?
我很欣赏你的评论。
嗨,对于android,我们可以通过本机代码找到,对于phonegap,我们需要编写一个插件,java代码如下
public String findDeviceID() {
String deviceID = null;
String serviceName = Context.TELEPHONY_SERVICE;
TelephonyManager m_telephonyManager = (TelephonyManager) getSystemService(serviceName);
int deviceType = m_telephonyManager.getPhoneType();
switch (deviceType) {
case (TelephonyManager.PHONE_TYPE_GSM):
break;
case (TelephonyManager.PHONE_TYPE_CDMA):
break;
case (TelephonyManager.PHONE_TYPE_NONE):
break;
default:
break;
}
deviceID = m_telephonyManager.getDeviceId();
return deviceID;
}
创建phonegap插件检查这个http://docs.phonegap.com/en/edge/guide_platforms_android_plugin.md.html#Android%20Plugins