Get extra intent data to read data from NFC
I'm using intent to active my app on a Nexus S phone. It works on active the app but can't receive data from NFC intent. I tried Titanium.Android.Intent.getData
and Titanium.Android.Intent.getStringExtra
but always return null. I used Titanium.Android.Intent.hasExtra
to check the keys should be there but can't take it out.
The code I use to test nfc keys :
var intent = Ti.Android.currentActivity.getIntent();
var v = intent.hasExtra("android.nfc.extra.NDEF_MESSAGES")+" - "+intent.hasExtra("android.nfc.extra.TAG"); // return true & true.
var alert = Ti.UI.createAlertDialog({ message: v });
alert.show();
Please help.
9 Answers
-
The Intents are handled by Android itself, and they can be passed to the application, but there will be a Ti.Android.NFC module in order to unwrap the NDEF messages. There is a lot of steps between registering the application to accept NFC and NDEF messages and the parsing of the data. We have created an NFC module that can read and write, you need to make sure that the application itself is creating the connection to transfer the data between the NFC tag and the application.
Each specific NDEF package requires its own set of instructions within your application for it to be compliant with NFC Forum specs. Its not as complicated as it seems, just a lot of binary message unwrapping :) Have a read of the Android.NFC docs or the actual specs of the NDEF on http://www.nfc-forum.org/specs/spec_list/.
Hope this helps, let me know if you have any specific questions happy to help :)
-
But how do you know that you are connected to the NFC?
I assume you would have to import NFC libraries in the Java code to get this working, or am I wrong?
-
Anybody can help? OR even tell me current version of Ti is not support NFC data read.
-
Antonio, I have checked out the modules area and cannot find any NFC module as you specify, is it somewhere else. To me it looks like there are in fact no support yet for NFC on Titanium . .
-
Any news on this module? I need NFC as well and would like to buy/use this module.
-
Hi Christoph, we are currently working on our own solution to this, probably a module, but we are considering extending titanium core as well, let me know your time frame of need, please . .
Regards
/Jörgen Buder
ATP, Purple Scout AB -
@Fredrik, are you too in need of this, even though your post is old here? ;)
-
Any update on this module? I need this for my andriod app and ready to buy this module..
-
Umair, I am sorry to say that we have had other clients with projects that pay us way more than this modules right now, even so I have not given up on this as I am close to getting it right, however you should know that I will only be able to give you a payload of the card content, which means that you have to interpret your payload yourself, this is due to the fact that all cards can basically have any content structure and so I would not know what that looks like. In any case we can help you specifically with that but it would cost you more money. It would be great if you could specify the requirements you have on the module, read? Save? Change? Etc etc?