【问题标题】:Setting Android WebView platform parameters or flags to Mobile将 Android WebView 平台参数或标志设置为 Mobile
【发布时间】:2017-02-14 18:14:25
【问题描述】:

我在 Android 应用程序中运行 WebView,需要强制将平台参数或标志或任何内容设置为“Mobile”而不是默认的“Web”。换句话说,我需要 WebView 发出的请求(调用)来表明平台是用于“移动”或“应用内”而不是“Web”请求。

我没有找到有关如何执行此操作或类似操作的文档。 Android 开发者文档没有提供足够的底层信息来说明如何执行上述操作。

【问题讨论】:

    标签: android webview parameters android-webview settings


    【解决方案1】:

    您可以设置自定义 webview 客户端并跟踪所有 url。

    WebViewClient myclient = new WebViewClient() {
           @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                // Trace the Url here
                return super.shouldOverrideUrlLoading(view, url);
            }
    
            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);
                // Trace the Url here
            }
    
            @Override
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                super.onReceivedError(view, errorCode, description, failingUrl);
                // Trace the Url here
            }
    
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                // Trace the Url here
            }
        };
        mWebView.setWebViewClient(myclient);
    

    如果有帮助,请投票。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多