Android Question Android tutorial - NFC reading and writing: Error occurred on line: 38 (Main)

Mr.Marc

Member
Licensed User
I have downloaded the file AdvancedNFC.zip from here https://www.b4x.com/android/forum/threads/nfc-reading-and-writing.64451/

I try to run it and I get an error on line 38. How can I solve this?

Logger connected to: emulator-5554
--------- beginning of main
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 38 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.nfc.NfcAdapter.enableForegroundDispatch(android.app.Activity, android.app.PendingIntent, android.content.IntentFilter[], java.lang.String[][])' on a null object reference
at anywheresoftware.b4a.objects.NFC.EnableForegroundDispatch(NFC.java:91)
at b4a.example.main._activity_resume(main.java:415)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at b4a.example.main.afterFirstLayout(main.java:108)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
 

Mr.Marc

Member
Licensed User
Well I must say I am confused. I have a NXP RD710 (pedago) NFC reader https://www.nxp.com/docs/en/application-note/AN10990.pdf that is connected to with my computer with a USB. I can detect my NFC tag with NXP RFIDDiscover and the NFC reader. I don't use an NFC android phone because my phone is broken. I doubt you can emulate an NFC android phone. I can't even compile the code and create the app. I should be able to create the app because I will only try to detect the NFC tag after I have created the android app and got it working.
 
Upvote 0

Mr.Marc

Member
Licensed User
Enable NFC before. Or your device is not supported.

Can I only use the AdvancedNFC library with the B4A bridge and a NFC android phone or can I use the AdvancedNFC library on B4A and a NFC reader that is connected to my computer with a USB cable?
 
Upvote 0

jahswant

Well-Known Member
Licensed User
Longtime User
The advanced NFC exemple is for phone enabled NFC devices. You'll have to find( maybe an SDK) to interfere with your NFC reader.
 
Upvote 0
Top