Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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.

— asked September 16th 2011 by Semon Xue
  • android
  • getdata
  • intent
  • nfc
0 Comments

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 :)

    — answered January 2nd 2012 by antonio kaplan
    permalink
    2 Comments
    • I would love to purchase the module. Is it for sale?

      — commented January 30th 2012 by Ryan Hickman
    • I would like too.

      — commented January 30th 2012 by Semon Xue
  • 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?

    — answered September 17th 2011 by Fredrik Davidsson
    permalink
    3 Comments
    • NFC reader function is build-in in my nexus s. I use intent filter to register my app as a reader. When I put NFC tag near my phone ,the app launch.

      — commented September 17th 2011 by Semon Xue
    • You can check the demo code on http://nfc.android.com/.

      — commented September 17th 2011 by Semon Xue
    • hi Semon, could you help me out with NFC for android? I really like using Titanium but recently hit a bump when trying to integrate NFC for my application.

      Would appreciate it if you could drop me some sample code or just an email at goh.zhengda@gmail.com. Thanks!!

      — commented October 31st 2011 by Zheng Da Clinton Goh
  • Anybody can help? OR even tell me current version of Ti is not support NFC data read.

    — answered December 18th 2011 by Semon Xue
    permalink
    0 Comments
  • 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 . .

    — answered March 15th 2012 by Jorgen Buder
    permalink
    0 Comments
  • Any news on this module? I need NFC as well and would like to buy/use this module.

    — answered May 19th 2012 by Christoph Schäfer
    permalink
    0 Comments
  • 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

    — answered May 21st 2012 by Jorgen Buder
    permalink
    2 Comments
    • Hi Jorgen, we are also looking for a solution, a module would be perfect, we are in need of this and do have a serious client.

      Regards
      Bob Rockland

      — commented May 23rd 2012 by Bob Rockland
    • Hi Jörgen,

      We have a busines case where we currently use qr codes and want to support nfc as soon as possible - for us this is mission critical, because nfc makes to "scan" process much easier and faster. A module would be perfekt for us as well :-)

      Let me know if I can contribute anything in order to speed things up!

      Regards,
      Christoph

      — commented May 23rd 2012 by Christoph Schäfer
  • @Fredrik, are you too in need of this, even though your post is old here? ;)

    — answered May 21st 2012 by Jorgen Buder
    permalink
    1 Comment
    • @Jörgen we would love to test it but we don't have a customer use case yet.

      — commented May 21st 2012 by Fredrik Davidsson
  • Any update on this module? I need this for my andriod app and ready to buy this module..

    — answered August 31st 2012 by Umair Jaffar
    permalink
    0 Comments
  • 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?

    — answered September 3rd 2012 by Jorgen Buder
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.