Search code examples
androidandroid-webviewgoogle-docsgoogle-docs-api

Remove sign in button in google docs webview in android


I am showing PDF files by using google docs in WebView in android. How to remove or hide "Sign In" button? I have attached screenshot below. Thanks in advance.

webview = (WebView) findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("https://docs.google.com/viewer?url=http://www.ex.com/terms.pdf");
webview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
});

enter image description here


Solution

  • Add the embedded=true parameter.

    webview = (WebView) findViewById(R.id.webView1);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.loadUrl("https://docs.google.com/viewer?embedded=true&url=https://orimi.com/pdf-test.pdf");
    webview.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return false;
        }
    });
    

    Note: This answer was actually proposed by user3777879. Tested, and working, he should get the credit - Stuart