Android Tutorial NFC - Reading and Writing

Status
Not open for further replies.

Dey

Active Member
Licensed User
Longtime User
Help
Tabled
HANNSPAD 13.3" SN14T71
NO NFC

ACR122U USB EXTERNAL +
External NFC Reader Service
https://play.google.com/store/apps/details?id=com.skjolberg.nfc.external

NFCAdvenced
Log:
LogCat connected to: 23NB9EZV7P
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
main_activity_resume (java line: 349)
java.lang.NullPointerException
at anywheresoftware.b4a.objects.NFC.EnableForegroundDispatch(NFC.java:91)
at b4a.example.main._activity_resume(main.java:349)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
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:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:801)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:617)
at dalvik.system.NativeStart.main(Native Method)


 

DonManfred

Expert
Licensed User
Longtime User
EnableForegroundDispatch
This is only available when the device has NFC

http://developer.android.com/intl/es/reference/android/nfc/NfcAdapter.html


I think you need to get the nfc reader to work another way.

From the app description from the link to ap you posted:
Note to non-developers: It is pretty close, but this is not a drop-in replacement for built-in NFC. That would require a custom ROM.

Check out the public API at https://github.com/skjolber/external-nfc-api.

See https://github.com/skjolber/external-nfc-api
 

DavideV

Active Member
Licensed User
Longtime User
ok i thougth it was javaobject. But now i can't understand how to integrate these lines into the example in the first post
 

Duncan H Williamson

Member
Licensed User
Longtime User
I really apreciate the help I have recieved on this topic... but I have yet another question... I am trying to write a URL to a tag so that when it is scanned by another nfc device it will open a web page... to date I have had no success... I can write the URL but it is just read as a line of text.. I have looked through the android documentation mentioned in responses to this topic but have been unable to get this to work... Could anyone point me in the right direction please ?

Regards

Duncan
 

DavideV

Active Member
Licensed User
Longtime User

Hi, you must set the correct payload,
if i'm not wrong these are payloads type for NDEF
0x00 = text
0x01 = http://www.
0x02 = https://www.
0x03 = http://

take a look at this lib, maybe you can reuse some code...
https://www.b4x.com/android/forum/threads/nfc-tagwriter-and-ibeacon-libraries-for-free.42137/
 

pixsys

Member
Licensed User
Longtime User
Hello,
I'm using this great lib to write an nfcv tag, calling transceive.

My question is, while queueing many different calls (writes at different offsets) will they always be executed in the calling order? or should i use flags in the _RunAsync methods and a timer(to periodically check those flags) to wait for one write completion before queuing the next?

Thanks alot
 
Last edited:

Peter Webb

Member
Licensed User
Hi, I have been playing with the excellent NFC library listed here. I can read Ndef tags with no issues. How can i modify this code to read the other NFC tag types available to Android? I have searched all over the net and can not find a B4A example of reading multiple NFC tag formats.

Can anyone assist me please?

Peter
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…