Answer the question
In order to leave comments, you need to log in
How to secure JavascriptInterface methods while tracking WebView URL?
There is JavascriptInterface class for JS interaction in WebView and Java android.
class JavaScriptInterface {
Context mContext;
WebView mW;
JavaScriptInterface(Context c,WebView w) {
mContext = c;
mW = w;
}
@JavascriptInterface
public void saveJson(String json) {
if(mW.getUrl().indexOf("file:///android_asset/") == 0){
if(mContext instanceof MainActivity)
((MainActivity)mContext).saveFL(json);
}
}
@JavascriptInterface
public String loadJson() {
if(mW.getUrl().indexOf("file:///android_asset/") == 0){
if(mContext instanceof MainActivity)
return ((MainActivity)mContext).loadFL();
}
return "[]";
}
A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same thread.
Answer the question
In order to leave comments, you need to log in
I would look towards adding/removing JavascriptInterface somewhere around WebViewClient::onPageStarted.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question