android - 不应调用 WebView.addJavascriptInterface

标签 android android-studio android-webview

AndroidStudio 开始向我显示警告“不应调用 WebView.addJavascriptInterface”。但是这种方法存在并且没有被弃用。它出什么问题了?可能是我遗漏了什么,现在有更好的方法与 Javascript 进行交互?

最佳答案

它在早期的 Android 版本中存在已知的安全漏洞。来自 the docs :

This is a powerful feature, but also presents a security risk for applications targeted to API level JELLY_BEAN or below, because JavaScript could use reflection to access an injected object's public fields. Use of this method in a WebView containing untrusted content could allow an attacker to manipulate the host application in unintended ways, executing Java code with the permissions of the host application. Use extreme care when using this method in a WebView which could contain untrusted content.

关于android - 不应调用 WebView.addJavascriptInterface,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23656329/

相关文章:

java - 如果出现 404 错误则重定向链接

android - 如何为 View 创建 UI 等首选项

android - Android 项目中包含资源的 Java 库 (.jar)

android - 如何在像 Vigo Video Hypstar 这样的摄像机上实时预览录像机的变化

Android Studio 外部 native 构建预编译 header

android - 任务 ':app:transformClassesWithShrinkResForDebug' 执行失败

android - 使用 Kotlin 语言在 Android Studio 中设置文本的渐变颜色

java - 如何从webview下载文件

机器人 : html loaded without font

android - 如何让 Android WebView 不忽略 'height' css 属性?