【问题标题】:Is there a way i can detect if a form was submited on a webview?有没有办法可以检测表单是否在 webview 上提交?
【发布时间】:2017-12-08 01:00:48
【问题描述】:

我有第三方支付公司的 webview。我不想获取发布数据,我只想知道用户是否已经提交以锁定应用程序中的操作,因此在该过程完成之前他不能做任何事情。

根据 android 文档 WebViewCLient 不会在 shouldOverrideUrlLoading() 上使用 post 方法执行此操作。

【问题讨论】:

    标签: android webview submit


    【解决方案1】:

    我没有找到完全做到这一点的方法,但我的解决方法是在 Web 客户端上覆盖 shouldInterceptRequest(WebView view, WebResourceRequest request),然后在那里使用 request.hasGesture() 来知道该请求是由用户触发的行动

    私有最终 WebViewClient webViewClient = new WebViewClient() {
    @覆盖
            public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
    
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    if(request.hasGesture()){
                        //屏蔽屏幕
                    }
                }
    
                返回 super.shouldInterceptRequest(view, request);
            }
    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-26
      • 2011-06-18
      • 2013-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多