android - show pdf in webview not works -


i showing pdf google docs in webview. using url google drive. tried many formats google drive, have no luck. url link below

https://drive.google.com/drive/u/0/folders/0bxd-5rffh6bufmniys16nfzkn2jmyzd3tjgtwmxleez2snlma2l2rdhmylnytdgtuxzodnm 

my activity class foloows"

public class formwebviewactivity extends customwindow {  int value; static string position_id = "position"; // webview webview;  progressbar progressbar_webview;  @suppresswarnings("deprecation") @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      try {          webview webview = new webview(formwebviewactivity.this);         webview.getsettings().setjavascriptenabled(true);         webview.getsettings().setpluginstate(pluginstate.on);          string pdfurl = "https://drive.google.com/drive/u/0/folders/0bxd-5rffh6bufmniys16nfzkn2jmyzd3tjgtwmxleez2snlma2l2rdhmylnytdgtuxzodnm";         // https://drive.google.com/file/d/0bxd-5rffh6buslhnthjsmw5hclk/view          webview.setwebviewclient(new webviewclient() {              @override             public void onpagefinished(webview view, string url) {                  super.onpagefinished(view, url);                 // progressbar_webview.setvisibility(view.gone);             }             @override             public void onpagestarted(webview view, string url,                     bitmap favicon) {                  super.onpagestarted(view, url, favicon);                 // progressbar_webview.setvisibility(view.visible);             }             @override             public boolean shouldoverrideurlloading(webview view, string url) {                 // view.loadurl(url);                 return false;             }          });          webview.loadurl("http://docs.google.com/gview?embedded=true&url="                 + pdfurl);         setcontentview(webview);      } catch (runtimeexception e) {         e.printstacktrace();     }     // webview webview = new webview(formwebviewactivity.this); } 

}

but shows html code, not actual pdf view. putting wrong google drive url? or it's not possible show google drive.

any free web hosting pdf file appreciated.

in addition @derek fung's answer, if drive having login session may need provide session access well.

but if use view url user not propted login there google account.

simply can use this::

 webview.loadurl("https://docs.google.com/viewer?url="+ pdfurl); 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -