简体   繁体   English

从JavaScript调用Android本机Java代码

[英]Calling android native java code from javascript

I would like to develop an application to transfer files between the android device and PC over wifi. 我想开发一个应用程序,以通过wifi在android设备和PC之间传输文件。

I have a webserver and a service set up and when a button is clicked the web server service is called and it serves a html page from the assets folder over http. 我有一个Web服务器和一个服务,当单击一个按钮时,将调用Web服务器服务,它通过http从资源文件夹中提供一个html页面。 This page could be accessed over wifi by typing the ip address of the phone:port number. 可以通过输入电话:端口号的IP地址通过wifi访问此页面。

But to do something useful with the application,I have been looking for a way to call native android code from the javascript functions in the html page. 但是为了对应用程序做一些有用的事情,我一直在寻找一种从html页面中的javascript函数调用本机android代码的方法。

Most of the examples I have looked for involve calling android code from webview. 我寻找的大多数示例都涉及从webview调用android代码。 I was wondering if there was a way to call it from javascript without web view/dummy web view. 我想知道是否有办法从javascript调用它不Web视图/虚拟的网络视图。

Any pointers in the right direction would be greatly appreciated. 朝正确方向的任何指针将不胜感激。

I was wondering if there was a way to call it from javascript without web view/dummy web view. 我想知道是否有办法从javascript调用它不Web视图/虚拟的网络视图。

No, for obvious security and privacy reasons. 不,出于明显的安全和隐私原因。

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

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