Hi everybody,
I write this post because I hope to help people that like me use NFC, and find somebody that can help to solve some problems that I found.
Two months ago I started to work with NFC and the great App Inventor, unfortunately I saw that it wasn't possible to do a lot of things, so I decided, for the first time, to create my own extension and I started with Mifare Classic RFID Technology because I know something about it .NFC and Mifare UID Extension
After that some people asked me to add features about different RFID tags because they really need and they do not have in the actual Near Field component. So I started to study what can I do.
This is the results of my test, to enable your app to recognise the different kinds of RFID tecnology You have to add in the AndroidManifest.xml of your apk :
and in the xml folder of the apk you have to add the nfc_tech_list.xml here an example:
as You understand the most important rows to add in the manifest is android.nfc.action.TECH_DISCOVERED when You approach a tag near your phone your app check the nfc_tech_list and if there is a match Your app can manage the data.
For example with my extension I was able to read the UID of Mifare Ultralight, NTAG213, NTAG215.
Nice, but really I don't like to add manually all this things to the apk file. I would like to do it directly to the extension!!
Well something it is possible but not everything ( my opinion, but I hope I am wrong) as I found in documentation App Inventor Annotations https://docs.google.com/document/d/1UsjVC6bjf4rKPLP6FULUPeB6C8O-A5GbpYjvvwqTYK8/edit#heading=h.jyvtlmbuvwhc
You can add Activities and Metadata in the extension as We need in the AndroidManifest.xml
and the extension is compiled successfully, but when You try to compile tha app that use the extension You have errors, and the problem (I suppose) is that You have not added the nfc_tech_list.xml in the correct folder, and actually I do not how to do automatically in the extension!!!!! (really need help for this)
Another important thing that I saw in my test (adding manually the things that I told above) is when You approach a Tag to the phone if You have others apps installed that use NFC, Android ask which app want to use.
This problem can be solved using the foreground dispatch, so your app opened has the priority to other app installed that handle the same intent:
https://developer.android.com/guide/topics/connectivity/nfc/advanced-nfc.html#foreground-dispatch
Now the problem (for me) is how to handle this on a extension, for example in the article above is written: 1. Add the following code in the onCreate()
method of your activity
How can I add a onCreate() on a extension, is it possible? I did not find an example.
Is it the correct way to do it? or there is another approach.
Well I think I said all, this is what I was able to do and understand, I hope this is a way to improve the NFC support in App Inventor
Best Regards
Marco