1. Are you ready for the Galaxy S20? Here is everything we know so far!

Pdf file issue while view from share point online server

Discussion in 'Android Development' started by Rajarajanigrid, Aug 16, 2018.

  1. Rajarajanigrid

    Thread Starter

    We Access pdf files from share point server.. to android webview

    Problems:

    1. It shows "No preview available"

    2. Some time its shows <!Doctype Html ... Error content..

    I used the below code snip...

    webView = findViewById(R.id.webview);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setPluginState(WebSettings.PluginState.ON);
    webView.getSettings().setAllowFileAccess(true);
    webView.getSettings().getJavaScriptCanOpenWindowsAutomatically();
    webView.getSettings().getAllowUniversalAccessFromFileURLs();
    webView.setWebChromeClient(new WebChromeClient());
    webView.loadUrl("https://docs.google.com/gview?embedded=true&url="+uri);
    CommonUtils.showDialog(WebViewActivity.this,"");

    webView.setWebViewClient(new WebViewClient()
    {
    @override
    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request)
    {
    view.loadUrl(request.getUrl().toString());
    return true;
    }

    @override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
    view.loadUrl(url);
    return true;
    }

    @override
    public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    CommonUtils.dismissDialog();
    }

    @override
    public void onReceivedError(WebView view, int errorCode,String description,String failingUrl) {
    // super.onReceivedError(view, request, error);
    Toast.makeText(WebViewActivity.this,"Error"+description, Toast.LENGTH_SHORT).show();
    }
    });
     


Loading...

Share This Page

Loading...