您的应用程序包含一个易受跨应用程序脚本攻击的WebView

时间:2019-12-07 05:53:00

标签: android android-webview

在Play商店上发布应用程序后出现问题

  

您的应用程序包含一个易受跨应用程序脚本攻击的WebView。有关详细信息,请参见Google帮助>中心文章。

     

弱势阶层:

     

com.all.in.one.shopping.app.india.activity.WebViewActivity-> setupWebView

这是我的webViewActivity代码-

class WebViewActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_web_view)

    setupWebView()
}

private fun setupWebView() {
    webViewFromActivity.loadUrl(intent.getStringExtra(AppConstants.WV_URL))
    webViewFromActivity.webViewClient = mWebViewClient
    webViewFromActivity.settings.javaScriptEnabled = true
    webViewFromActivity.settings.domStorageEnabled = true
    webViewFromActivity.requestFocus(View.FOCUS_DOWN)
}

private val mWebViewClient = object : WebViewClient() {
    override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {
        progressBar.visibility = View.VISIBLE
        super.onPageStarted(view, url, favicon)

    }

    override fun shouldOverrideUrlLoading(view: WebView, url: String?): Boolean {
        view.loadUrl(url)
        return true
    }

    override fun onPageFinished(view: WebView, url: String) {
        progressBar.visibility = View.GONE
        super.onPageFinished(view, url)
    }

2 个答案:

答案 0 :(得分:0)

因为这个原因:

webViewFromActivity.settings.javaScriptEnabled = true

答案 1 :(得分:0)

尝试在清单中添加以下内容

<meta-data android:name="android.webkit.WebView.EnableSafeBrowsing"
android:value="true" />