如何获得在PhoneGap的移动应用程序IMEI号码,SIM卡号码,手机号码?手机号码、卡号、如何获得、应用程序

由网友(烟酒释情伤)分享简介:我需要得到的IMEI号码,手机号码,SIM卡号码在PhoneGap的构建HTML的移动web应用程序为Android I need to get the IMEI number, Mobile number, SIM number in a Phonegap build HTML mobile web applica...

我需要得到的IMEI号码,手机号码,SIM卡号码在PhoneGap的构建HTML的移动web应用程序为Android

I need to get the IMEI number, Mobile number, SIM number in a Phonegap build HTML mobile web application for android

推荐答案

您不能让他们直接。

选项1)找一些插件,我不知道,如果他们存在与否。

Option 1) look for some plugin I'm not sure if they exist or not.

选项2)自己写的小脚本返回需要的是什么。

Option 2) Write your own small script which returns what is needed.

例如我用这个JavaScript code,以获得IMEI在我的应用程序的一种:

For example I use this javascript code to get the IMEI in one of my app's:

$imei=window.YourActivityName.get_imei();

对于这个工作,你需要启用JavaScript在您的应用程序,并在Java中定义功能get_imei()。

For this to work you need to enable javascript in your app and define function get_imei() in Java.

您的Java应该是这个样子:

Your Java should look something like:

public class YourActivityName extends CordovaActivity 
{
.........
public void onCreate(Bundle savedInstanceState)
{
 .......
 appView.addJavascriptInterface(this, "YourActivityName");
 super.loadUrl(Config.getStartUrl(), 10000);
 .......
}

//Define function to return imei in Java:
@JavascriptInterface
public String get_imei() {
     TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    String imei = telephonyManager.getDeviceId();
    return imei;    
}
}
阅读全文

相关推荐

最新文章