java - How to display a local html file in Android? -
i wanted display simple html page in webview in android, made assets
folder in main , put test.html
file, when run app, web page not available code
public class androidhtmlactivity extends activity { webview mybrowser; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); mybrowser = (webview)findviewbyid(r.id.mybrowser); final myjavascriptinterface myjavascriptinterface = new myjavascriptinterface(this); mybrowser.addjavascriptinterface(myjavascriptinterface, "androidfunction"); mybrowser.getsettings().setjavascriptenabled(true); mybrowser.loadurl("file:///assets/test.html"); } }
for accessing asset folder need use android_asset
.
hence code should be,
mybrowser.loadurl("file:///android_asset/test.html");
Comments
Post a Comment