Android- using addJavaScriptInterface to return a value from Javascript

后端 未结 3 2027
猫巷女王i
猫巷女王i 2020-12-30 14:50

So i know there are other posts addressing the same issue, and I think I\'ve followed them to the letter but alas to no avail. I\'m trying to learn how to get my app to int

3条回答
  •  旧时难觅i
    2020-12-30 15:45

    This may not be correct, I will have to double check but it may be due to the reference being lost..

    Try making your ClsAccessor reference a member level one..

    public class JSExample extends Activity {
        ...
        ClsAccessor _accessor = new ClsAccessor();
        ...
        public void onCreate(Bundle savedInstanceState) {
            ...
            mWebView.addJavascriptInterface(_accessor, "accessor");
            ...
    

    Also if you debug line by line does setValue() ever get called in managed code?

    For what it is worth, I have code that is doing as I have described above and the script to managed interface works fine, however I am not in a position currently to test and see if not having a reference to the class also works.

提交回复
热议问题