如何在android设备上的ionic2中获取IMEI

时间:2016-09-07 09:30:04

标签: android cordova ionic-framework ionic2

我试图在离子2中获得一个Android设备的imei,但到目前为止还没有运气。

在离子1 l中,我刚刚使用了一个像cordova-uid https://github.com/hygieiasoft/cordova-plugin-uid这样的ngCordova插件。

是否有一个离子原生插件我可以用它来获取imei,还是有其他方法可以获得imei。

3 个答案:

答案 0 :(得分:1)

可以使用此代码。

  

cordova插件添加org.hygieiasoft.cordova.uid

或者

  

cordova插件添加https://github.com/hygieiasoft/cordova-plugin-uid

对于测试用途console.log

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject

class ProgressBarWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="ProgressBar Demo")
        self.set_border_width(10)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.add(vbox)

        self.progressbar = Gtk.ProgressBar()
        vbox.pack_start(self.progressbar, True, True, 0)

        button = Gtk.CheckButton("Show text")
        button.connect("toggled", self.on_show_text_toggled)
        vbox.pack_start(button, True, True, 0)

        button = Gtk.CheckButton("Activity mode")
        button.connect("toggled", self.on_activity_mode_toggled)
        vbox.pack_start(button, True, True, 0)

        button = Gtk.CheckButton("Right to Left")
        button.connect("toggled", self.on_right_to_left_toggled)
        vbox.pack_start(button, True, True, 0)

        self.timeout_id = GObject.timeout_add(50, self.on_timeout, None)
        self.activity_mode = False

    def on_show_text_toggled(self, button):
        show_text = button.get_active()
        if show_text:
            text = "some text"
        else:
            text = None
        self.progressbar.set_text(text)
        self.progressbar.set_show_text(show_text)

    def on_activity_mode_toggled(self, button):
        self.activity_mode = button.get_active()
        if self.activity_mode:
            self.progressbar.pulse()
        else:
            self.progressbar.set_fraction(0.0)

    def on_right_to_left_toggled(self, button):
        value = button.get_active()
        self.progressbar.set_inverted(value)

    def on_timeout(self, user_data):
        """
        Update value on the progress bar
        """
        if self.activity_mode:
            self.progressbar.pulse()
        else:
            new_value = self.progressbar.get_fraction() + 0.01

            if new_value > 1:
                new_value = 0

            self.progressbar.set_fraction(new_value)

        # As this is a timeout function, return True so that it
        # continues to get called
        return True

win = ProgressBarWindow() win.connect("delete-event", Gtk.main_quit)
win.show_all() Gtk.main()

答案 1 :(得分:0)

响应中的deviceId与imei相同。您可以执行以下

b

答案 2 :(得分:-1)

点击此链接https://www.npmjs.com/package/cordova-plugin-sim

通过

安装插件
df1 <- structure(list(VAR1 = c("A", "B"), VAR2 = c("D", "D"), AUS1 = c(23L, 
55L), AUS2 = c(234L, 76L), AUS3 = c(34L, 55L), AUS4 = c(856L, 
36L), AUS56 = c(99L, 6456L), VAR3 = c(0L, 0L), VAR4 = c("FCK", 
"XYC")), .Names = c("VAR1", "VAR2", "AUS1", "AUS2", "AUS3", "AUS4", 
 "AUS56", "VAR3", "VAR4"), class = "data.frame", row.names = c(NA, 
-2L))

使用代码

cordova plugin add cordova-plugin-sim