Android provides a WebView object for web browsing.
1, want to use WebView, first should give permission:internet.
2. WebView Loading HTML Document
3. Call Android object in WebView using javascript: websettings.setjavascriptenabled (TRUE);
public class Jscallandroid extends Activity {WebView mywebview; @Overridepublic void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.main); Mywebview = (WebView) Findviewbyid (R.id.webview );//Here to simplify programming, use the file protocol to load HTML pages in the local assets directory//or, if necessary, use the HTTP protocol to load the HTML page of the remote Web site. Mywebview.loadurl ("file:///android_asset/test.html");//Get WebView Settings object WebSettings websettings = Mywebview.getsettings ();//Turn on JavaScript call websettings.setjavascriptenabled (TRUE);//Expose MyObject object to JavaScript script// This way the JavaScript in the Test.html page can be called by MYOBJ to invoke the MyObject method Mywebview.addjavascriptinterface (new MyObject (This), "MYOBJ");}}
Android WebView Learning