javascript 有什么方法可以与Android中的WebView进行通信?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8341159/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 03:07:05  来源:igfitidea点击:

Any way to communicate with WebView in Android?

javascriptandroidhtmlandroid-webview

提问by znarf

Is it possible to interact with a webview in android trough my native android code?

是否可以通过我的原生 android 代码与 android 中的 webview 交互?

I develop can bus driver for android and I like to send my can bus data to a html 5 app in a webview without sending them over internet to a webservice. or is it possible to call funktions via the html 5 app in my native android app?

我为 android 开发了 can 总线驱动程序,我喜欢将我的 can 总线数据发送到 web 视图中的 html 5 应用程序,而不是通过互联网将它们发送到 web 服务。或者是否可以通过我的原生 android 应用程序中的 html 5 应用程序调用 funktions?

Do you know a good solution for that scenario?

您知道该场景的良好解决方案吗?

采纳答案by Felix

回答by Daniel Kurka

Here is a good example how to call javascript running inside the WebView:

这是一个很好的示例,如何调用在 WebView 中运行的 javascript:

http://android-er.blogspot.com/2011/10/call-javascript-inside-webview-from.html

http://android-er.blogspot.com/2011/10/call-javascript-inside-webview-from.html