I am developing an android app in which I have to load a PDF in a webview by appending http://drive.google.com/viewerng/viewer?embedded=true&url=
before the actual URL. But after loading it is not previewing the document and saying that "No Preview Available". But the same document is loaded in iOS webview and the Desktop chrome. At the same time, other PDF files from internet are loading properly. I dont know whether it is the issue with the file or my code. Here is my code
`
public class WebViewActivity extends AppCompatActivity {
private WebView webView;
private String postUrl;
private String doc_type;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
this.webView = (WebView) findViewById(R.id.webView);
this.webView.getSettings().setJavaScriptEnabled(true);
this.webView.setHorizontalScrollBarEnabled(false);
this.webView.getSettings().setAllowFileAccess(true);
doc_type = getIntent().getStringExtra("doc_type");
String url = getIntent().getStringExtra("click_action_url");
if (doc_type != null && doc_type.equalsIgnoreCase("others")) {
postUrl = url;
} else{
postUrl = "http://drive.google.com/viewerng/viewer?embedded=true&url=" + url;
}
this.webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
}
});
this.webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@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);
}
});
this.webView.loadUrl(postUrl);
}
}`
Someone please help.