Using Android intents to launch from NFC

You must Login before you can answer or comment on any questions.

I realize that there isn't currently any official or module Android NFC support in Titanium, however, I was wondering if anyone who is a bit more experienced on the Android side would know about the feasibility of launch a Titanium app via intents (preset in the manifest, presumably), and then passing the "Tag" param to the app.

This would, of course, forgo the ability to read and write tags while the app is in the foreground. In my crude understanding of Android services and intents support in Titanium, it would go something like Marshall Culpepper's example from January 2011 - http://developer.appcelerator.com/blog/2011/02/launching-activities-and-using-content-uris-in-android.html.

My silly belief is that you could do something like this:

listenForNfcLauncheButton.addEventListener("click", function(e) {
  var intent = Ti.Android.createIntent({
    action: "android.nfc.action.TAG_DISCOVERED"
  });
  var activity = Ti.Android.currentActivity;
  activity.startActivityForResult(intent, function(e) {
    Ti.API.info("launch app.js?")
    }
  });
});
...however I realize that there are some hurdles around where you would associate your tag URI/type with the intent. Thanks for wading through my ignorance on this one.

See also:

http://developer.android.com/guide/topics/nfc/index.html http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Android.Activity-object.html http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Android.Activity.startActivityForResult-method.html

Similar but more ambitious question by Yilun Fan

2 Answers

Cameron any luck in getting this to work?

— answered 2 years ago by Fredrik Davidsson
answer permalink
1 Comment
  • Sadly I haven't had time to work on this since I'm still converting our app from iPhone only to Android compatible. That said, I think this is the best approach without diving into the Java (yet).

    I wouldn't be surprised if this drops as a premium module (and I would pay for it!)

    — commented 2 years ago by Cameron Robertson

My code is work on launch app from NFC. But I still can't get data from tag. Do you have any idea?

My post & code : http://developer.appcelerator.com/question/125688/get-extra-intent-data-to-read-data-from-nfc

Your Answer

Think you can help? Login to answer this question!