in my android application I have to load PDFs in the server into a webview. according to a stack-overflow question I used Google DOC view in loading it. but my problem is some times it does not show the file in the webview while in another instance it displays quite well. I can't figure out the problem. but the code appears to be OK. my code segment is as below.
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 below.
<?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 the logcat output when it not showing the pdf.
this is the logcat output when it showing the pdf in the webview.
So whats the wrong with my code. how can I fix this. Thanks and regards!