如何获得在PhoneGap的移动应用程序IMEI号码,SIM卡号码,手机号码? [英] How to get IMEI number, SIM number, Mobile number in PhoneGap Mobile Application?

查看:153
本文介绍了如何获得在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 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;    
}
}

这篇关于如何获得在PhoneGap的移动应用程序IMEI号码,SIM卡号码,手机号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆