我试图在JNI图层中设置setNdefPushMessageCallback
。
为此,我将获得此方法ID:
public void setNdefPushMessageCallback (NfcAdapter.CreateNdefMessageCallback callback, Activity activity, Activity... activities)
这是我的代码:
jmethodID methodId = (*env)->GetMethodID(
env, cls, "setNdefPushMessageCallback",
"(Landroid/nfc/NfcAdapter/CreateNdefMessageCallback;[Landroid/app/Activity;)V;");
我也尝试过只给Landroid/app/Activity;
。但我得到java.lang.NoSuchMethodError
例外。请帮帮我在这种情况下我将使用的签名是什么?
08-20 11:02:01.451: E/AndroidRuntime(24550): FATAL EXCEPTION: main
08-20 11:02:01.451: E/AndroidRuntime(24550): Process: org.iotivity.ca.sample_service, PID: 24550
08-20 11:02:01.451: E/AndroidRuntime(24550): java.lang.NoSuchMethodError: no non-static method "Landroid/nfc/NfcAdapter;.setNdefPushMessageCallback(Landroid/nfc/NfcAdapter/CreateNdefMessageCallback;[Landroid/app/Activity;)V;"
答案 0 :(得分:1)
您对第一个参数使用了错误的签名:
CreateNdefMessageCallback
是NfcAdapter
的内部类。
将Landroid/nfc/NfcAdapter/CreateNdefMessageCallback
替换为Landroid/nfc/NfcAdapter$CreateNdefMessageCallback
编辑:
的对应签名
public void setNdefPushMessageCallback (NfcAdapter.CreateNdefMessageCallback callback, Activity activity, Activity... activities)
是
(Landroid/nfc/NfcAdapter$CreateNdefMessageCallback;Landroid/app/Activity;[Landroid/app/Activity;)V