WebSettings = Wvshowproduce.getsettings ();
Set the WebView property to be able to execute JavaScript scripts
Websettings.setjavascriptenabled (TRUE);
Settings can access files
Websettings.setallowfileaccess (TRUE);
Setting support Scaling
Websettings.setbuiltinzoomcontrols (FALSE);
Wvshowproduce.getsettings (). setrenderpriority (WebSettings.RenderPriority.HIGH);
Websettings.setcachemode (Websettings.load_default);//Open cache
Websettings.setsupportzoom (FALSE);
Websettings.setallowcontentaccess (TRUE);
Websettings.setjavascriptenabled (TRUE);
Websettings.setusewideviewport (TRUE);//Set this property to scale any scale
Websettings.setloadwithoverviewmode (TRUE);
Websettings.setloadsimagesautomatically (TRUE);
Websettings.setusewideviewport (TRUE);//adjust the picture to fit the webview size
Websettings.setblocknetworkimage (FALSE);
Wvshowproduce.addjavascriptinterface ((class's proxy name), "Ocmodel");
Load Web pages that need to be displayed
Wvshowproduce.loadurl (URL);
Make a jump page
Wvshowproduce.setwebviewclient (New Webviewclient () {
@Override
public boolean shouldoverrideurlloading (WebView view, String URL) {
if (! Textutils.isempty (URL)) {
LOG.I ("img", URL);
Intent intent1 = new Intent (myshowwebviewactivity.this, Myshowwebviewactivity.class);
Intent1.putextra (consts.key_sendentity2activity, URL);
StartActivity (INTENT1);
}
return true;
}
@Override
public void onpagestarted (WebView view, String URL, Bitmap favicon) {
super.onpagestarted (view, URL, favicon);
Rlprogress.setvisibility (view.visible);
}
@Override
public void onpagefinished (WebView view, String URL) {
super.onpagefinished (view, URL);
Rlprogress.setvisibility (View.gone);
Websettings.setblocknetworkimage (FALSE);
if (! Textutils.isempty (title)) {
if (Title.contains ("http") | | | title.contains ("Your domain name") | | title.contains ("local address") | | title.contains ("... ")) {
title = "";
}
Settitle (title);
} else {
Settitle ("");
}
}
@Override
public void Onreceivederror (WebView view, webresourcerequest request, webresourceerror error) {
Super.onreceivederror (view, request, error);
Rlprogress.setvisibility (View.gone);
Toastutil.showshort (Myshowwebviewactivity.this, "There is an error, please try again later");
}
});
Get title
Wvshowproduce.setwebchromeclient (New Webchromeclient () {
@Override
public void Onreceivedtitle (WebView view, String title) {
Super.onreceivedtitle (view, title);
String title_str = title;
if (Title.contains ("http") | | | title.contains ("") | | Title.contains ("") | | Title.contains ("")) {
Title_str = "";
}
MyShowWebViewActivity.this.title = Title_str;
Settitle (title);
}
});
Call JS
String call = "javascript: Method Name ()";
Wvshowproduce.loadurl (call);
JS Call Android
Wvshowproduce.addjavascriptinterface (New Ocmodel (), "Ocmodel");
public class Ocmodel {
share to a conversation
@JavascriptInterface
public void Sharewithcontent (String temp, final string data) {
}
Android WebView Combat