pub fn bind_proxy_handler(
proxy: &GlobalRef,
handler: impl Fn(&mut JNIEnv<'_>, &JObject<'_>, &JObjectArray<'_>) -> GlobalRef + Send + Sync + 'static,
)
Expand description
java动态代理绑定rust函数。
§Arguments
proxy
: 代理对象。handler
: 一个处理函数。
returns: ()
§Examples
use droid_wrap_utils::{bind_proxy_handler, new_proxy, vm_attach};
let proxy = new_proxy(&["java.lang.Runnable"]);
bind_proxy_handler(&proxy, |mut env, method, args| {
let name = env.call_method(&method, "getName", "()Ljava/lang/String;", &[]).unwrap().l().unwrap();
let name = env.get_string((&name).into()).unwrap();
println!("Method `{}` is called with proxy.", name.to_str().unwrap());
droid_wrap_utils::null_value(env)
});
vm_attach!(mut env);
env.call_method(&proxy, "run", "()V", &[]).unwrap();