简体   繁体   English

获取设备IMEI并将其通过WebView发送到网站

[英]Get device IMEI and send it through WebView to a website

I have an Android aplication which displays a web app (of mine) into a webview. 我有一个Android应用程序,可将一个Web应用程序(属于我的)显示到Web视图中。 For a certain reason I want to get the device IMEI as soon as the app is open, send it with javascript from the MainActivity.java (and through the webview) to my web app (which is located in a remote server). 出于某种原因,我想在打开应用程序后立即获取设备IMEI,将它与javascript一起从MainActivity.java(并通过webview)发送到我的Web应用程序(位于远程服务器中)。

I have an input hidden inside the app web, and I want to give it the IMEI as value. 我在应用程序网络中隐藏了一个输入,我想给它IMEI作为值。 Is that possible? 那可能吗? Is there any way to send the IMEI through JS in the mainActivity.java to get it in the html file? 有什么方法可以通过mainActivity.java中的JS通过IM发送IMEI以便在html文件中获取它?

What you can do is create a webserver on the mobile application that hosts a IMEI request api. 您可以做的是在承载IMEI请求api的移动应用程序上创建Web服务器。 Basically you make a simple webserver local to the application on your website you detect if the request is coming from your app typically you feed a GET variable to your site so it knows and then you activate the code that trys to run a ajax request to the local ip/port of the android device via js of course. 基本上,您会在网站上的应用程序本地创建一个简单的Web服务器,然后检测到请求是否来自您的应用程序。通常,您将GET变量提供给您的网站,以便它知道,然后激活尝试向其运行ajax请求的代码当然,通过js,Android设备的本地ip /端口。 then you submit the custom request to that url. 然后您向该网址提交自定义请求。 since javascript is ran locally on a phone it can do a web request locally. 由于javascript是在手机上本地运行的,因此可以在本地进行网络请求。

You can use this library to create a http server. 您可以使用此库来创建http服务器。 https://github.com/NanoHttpd/nanohttpd https://github.com/NanoHttpd/nanohttpd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM