Reputation: 1170
I am having webview in my app, i am loading website in my webview and in that website there are multiple links of PDF file but while i am clicking on that it is not opening in webview, if i am checking it in my windows's browser it opening. i have enabled javascript but no luck, i used following properties also
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setWebViewClient(new myWebClient());
Upvotes: 3
Views: 14903
Reputation: 121
Whenever you want to open pdf saved in google drive this code can be used
WebView view=(WebView)findViewById(R.id.webView);
view.setWebViewClient(new WebViewClient());
String url=getIntent().toString("value1");
String URL="https://docs.google.com/viewer?url="+url;
view.loadUrl(Url);
Upvotes: 1
Reputation: 76
this may help you,
String myPdfUrl = "http://example.com/awesome.pdf";
String url = "http://docs.google.com/gview?embedded=true&url=" + myPdfUrl;
Log.i(TAG, "Opening PDF: " + url);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
Upvotes: 1
Reputation: 12919
Android does not work like iOS in this respect. The WebView widget cannot display PDF documents on Android.
You will have to:
Use a third party library (unfortunately, most open source pdf libs are GPL)
Open a pdf viewer app via an Intent
Use Google docs in a webview
Upvotes: 3