android4.4 to use JS injection, you can not use the old Loadurl () method, each load will refresh the page again.
But in 2. On the system version of X, the Evaluatejavascript method will report an exception. Solution, I think of a, if there is a better way, please leave a message to tell me. Learn from each other.
The system version can be judged first: here:
@SuppressWarnings ("deprecation") public static int getandroidsdkversion () { int version=0; try { Version = integer.valueof (Android.os.Build.VERSION.SDK); } catch (NumberFormatException e) { } return version;}
Then decide whether to use Loadurl or Evaluatejavascript method to load the way to inject JS.
if (version<18) {webview.loadurl (JSSTR);} Else{webview.evaluatejavascript (Jsstr, New valuecallback<string> () { @Override public Void Onreceivevalue (String value) { }});}}
Ok! that it is!
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
android4.4 Evaluatejavascript to Android2. Problems that cannot be called on X