简体   繁体   English

所有的JavaScript调用都可以在Hybrid Android应用中使用吗?

[英]Does all javascript calls work in Hybrid Android app?

I am building a Hybrid Android app using HTML5 and JavaScript. 我正在使用HTML5和JavaScript构建Hybrid Android应用。

In my app, I would be requiring to make system related calls such as getting the system's date and time. 在我的应用中,我需要进行与系统相关的调用,例如获取系统的日期和时间。

I was wondering as to whether such system related calls will work in Android? 我想知道这样的系统相关呼叫是否可以在Android中使用? Will they? 他们会吗?

  1. WebView.addJavascriptInterface() will allow you to inject an arbitrary Java object into the WebView. WebView.addJavascriptInterface()将允许您将任意Java对象注入WebView。
  2. JavaScript running on the WebView can then call methods of the Java object. 然后,在WebView上运行的JavaScript可以调用Java对象的方法。
  3. These methods then run Java code (possibly accessing Android API). 然后,这些方法将运行Java代码(可能会访问Android API)。
  4. These methods may return data back to the JavaScript on the WebView. 这些方法可以将数据返回到WebView上的JavaScript。

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

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