想开发NFC碰一碰功能,报错:java.lang.NullPointerException: Attempt to invoke virtual method 'void oh
在使用NFC开发碰一碰功能的代码:
NfcController.ReaderModeCallback stub = new NfcController.ReaderModeCallback()
nfcController.setReaderMode(this.getAbility(),stub,1, new PacMapEx());
这里报错报错
java.lang.NullPointerException: Attempt to invoke virtual method 'void ohos.aafwk.ability.HarmonyosApplication.registerAbilityLifecycleCallbacks(ohos.aafwk.ability.AbilityLifecycleCallbacks)' on a null object reference
at ohos.nfc.NfcAbilityManager$NfcAppState.register(NfcAbilityManager.java:73)
at ohos.nfc.NfcAbilityManager.registerHarmonyApplication(NfcAbilityManager.java:111)
at ohos.nfc.NfcAbilityManager$NfcAbilityState.<init>(NfcAbilityManager.java:146)
at ohos.nfc.NfcAbilityManager.getAbilityState(NfcAbilityManager.java:260)
at ohos.nfc.NfcAbilityManager.setReaderMode(NfcAbilityManager.java:218)
at ohos.nfc.NfcController.setReaderMode(NfcController.java:356)
你这个NfcController.ReaderModeCallback stub = new NfcController.ReaderModeCallback()
序列化的时候 先序列化NfcController,在NfcController中调用ReaderModeCallback 回调
相关能力还没开放,目前用不了吧。
想问一下这个问题解决了吗 也遇到了相同的问题