天天看點

java 回調js,将Java回調函數傳遞給JSNI方法?

java 回調js,将Java回調函數傳遞給JSNI方法?

I want to pass a success and a failure callback Java function to a JSNI method.

This is what I get so far but it does not work. How can I fix it?

package c;

public class A {

test(new Callback() {

@Override

public void onFailure(String reason) {

Window.alert("fail");

}

@Override

public void onSuccess(String result) {

Window.alert("suc");

}

});

native void test(Callback callback) ;

}

解決方案

You can call the callback methods in this way:

native void test(Callback callback) ;