Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS怎么传方法给JAVA进行执行 #7

Open
daliyan opened this issue Jul 13, 2015 · 1 comment
Open

JS怎么传方法给JAVA进行执行 #7

daliyan opened this issue Jul 13, 2015 · 1 comment

Comments

@daliyan
Copy link

daliyan commented Jul 13, 2015

在 JsCallJava的call方法中 有一个类型判断:values[k + 1] = new JsCallback(webView, mInjectedName, argsVals.getInt(k));进行执行的时候有一个argsVals.getInt(k)获取到对应的全局方法索引,但是假如我需要传入一个对应的方法名称(String 类型),需要怎么做,我没有看到onJsPrompt代码是怎么对message进行封装的,例如我检测到的:
message="{"method":"delayJsCallBack1","types":["number","string","function"],"args":[1,"call back haha","1"]}";其中1是message传过来的,请问我需要怎么做,期待您的回复。

@PengliangC
Copy link

我自己弄的
public class UseJsMethod {
WebView webView;
private Handler mHandler=new Handler();
public UseJsMethod(WebView webView) {
this.webView = webView;
}

public void useJsMethod(final String methodName) {
    mHandler.post(new Runnable() {
        public void run() {
            //use method in js
            webView.loadUrl("javascript:"+methodName+"()");
        }
    });
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants