如何获得在PhoneGap的IMEI号?如何获得、PhoneGap、IMEI

2023-09-12 22:39:16 作者:酒话学长

我使用jQuery,JavaScript和HTML开发PhoneGap的Andr​​oid手机应用程序。我想获得移动IMEI。我试图从这个本教程code 。

i'm developing a phonegap android mobile application using jquery,javascript and html. I want to get the mobile IMEI .I have tried this code from this Tutorial.

我收到的数量( 97734a345d234d )像this.I检查了我的设备使用*#06#。我不知道它是否是正确的还是错误的。请好心指点我拿到IMEI号码。在此先感谢。

I am getting the number(97734a345d234d)like this.I have checked my device to get imei number using *#06#.I dunno whether it is correct or wrong .Please kindly guide me.Thanks in Advance.

推荐答案

取在延伸DroidGap类的类的IMEI号码,节省了IMEI号的值静态成员,然后在任何你想访问该静态字段。 ..例如code是这里

Fetch the IMEI number in the class which extends DroidGap class and save the value of imei number in static member and then access this static field from where ever you want... example code is here

public class MyApp extends DroidGap
{
    private static String imei; 
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        imei=tm.getDeviceId();
    }
    static public String getIMEI(){
        return imei;
    }
}
// where ever u need imei number use this code

String imei=MyApp.getIMEI();