android - how to open pdf in webview without gdoc from Url -


i try open pdf url in webview below code , found solutions gdoc not useful me because want show pdf in view mode , user should not download , need clear cache after press

code :

    mwebview.setwebchromeclient(new webchromeclient());     websettings settings = mwebview.getsettings();     settings.setpluginstate(websettings.pluginstate.on);     mwebview.setwebviewclient(new mybrowser());     mwebview.setbackgroundcolor(0x00000000);     settings.setallowfileaccess(false);     settings.setbuiltinzoomcontrols(true);     settings.setsupportzoom(true);     settings.setusewideviewport(true);     settings.setloadwithoverviewmode(false);     settings.setsaveformdata(false);     settings.setjavascriptenabled(true); 

use code:

webview webview = (webview) findviewbyid(r.id.my_webview); webview.setwebviewclient(new mywebviewclient()); webview.addview(webview.getzoomcontrols()); webview.getsettings().setjavascriptenabled(true); webview.loadurl("http://docs.google.com/gview?embedded=true&url=**pdfurl**"); 

also, add permission in manifest needs internet connectivity (must required)

<uses-permission android:name="android.permission.internet"/> 

this work!

if direct url not work lode this

webview.getsettings().setpluginsenabled(true); webview.getsettings().setallowfileaccess(true); webview.loadurl(pdf); 

also,

string pdf="<iframe src='http://docs.google.com/viewer?url=+location pdf file+'            width='100%' height='100%'            style='border: none;'></iframe>"; 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo