Download PDFs to Android Web View

in my android application i need to upload pdf to server in webview . according to the question, I used the Google DOC view at boot time. but my problem doesn’t show the file several times in webview , while in another instance it shows up quite well. I can not understand the problem. but the code looks fine. my code segment is as follows.

WebViewLable.getSettings().setJavaScriptEnabled(true);    
    WebViewLable.getSettings().setLoadWithOverviewMode(true);
    WebViewLable.getSettings().setUseWideViewPort(true);  

    fullURL=GoogleDOCview+"https://livefarmer.com/labels/"+itemURL;
    WebViewLable.loadUrl(fullURL);

}

private class Callback extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(
            WebView view, String url) {
        return(false);
    }
}

and my webview is as follows.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/app_bg_black"
    android:orientation="vertical" >

    <include
        android:id="@+id/nav_bar"
        android:layout_width="fill_parent"
        layout="@layout/nav_bar" />


    <WebView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webViewLable"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:windowSoftInputMode="adjustResize" />

</LinearLayout>

this is logcat output when it does not show pdf.

enter image description here

this is logcat output when it shows pdf in webview.

enter image description here

So what's wrong with my code. How can I fix this. Thank you and welcome!

+2
2
String PdfUrl = "http://pdfexample.com/abcd.pdf";
String url = "http://docs.google.com/gview?embedded=true&url=" + PdfUrl;
Log.i(TAG, "PDF URL : " + url);
webView.getSettings().setJavaScriptEnabled(true); 
webView.loadUrl(url);

+2

, , WebView , 0, URL.

        myWebView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                if (view.getContentHeight() == 0) setUrl();
            }
        });

setUrl() :

private void setUrl() {
     myWebView.loadUrl("http://docs.google.com/gview?embedded=true&url=" + pdfUrl);
}
0

All Articles