1

ICS introduces the possibility to share an application via Android Beam using NFC, and as far as I understood if an app is opened on deviceA it will automatically be started on deviceB (if it's already installed on it, otherwise the Market app will open) when the devices are close enough and a user "touches to beam" it. Is there a way, inside the launcher Activity, to detect if it has been started because of a NFC message or because of a user interaction?

Josh Lee
  • 171,072
  • 38
  • 269
  • 275
futtetennista
  • 1,876
  • 1
  • 20
  • 33
  • Sorry for the laziness today. But http://developer.android.com/guide/topics/nfc/nfc.html is a great resource. The gist of it is, you will get a different intent, so check for the NFC tag action. – Mike dg Jan 23 '12 at 16:55
  • I read that but it didn't help (or I'm REALLY missing something here). The "you will get a different intent" bit of you comment is not true, I debugged my app when it's started via NFC: the action is `android.intent.action.MAIN` and the category is `android.intent.category.LAUNCHER`, so the standard one. – futtetennista Feb 01 '12 at 14:15

2 Answers2

0

Only NFC Intents are started when a beam occurs. These are ACTION_NDEF_DISCOVERED, ACTION_TECH_DISCOVERED, or ACTION_TAG_DISCOVERED. Check out the beaming section of the dev guide for how to handle beams: http://developer.android.com/guide/topics/nfc/nfc.html#p2p

robertly
  • 2,132
  • 14
  • 9
0

In case the Android Beam (or NDEF) message contains an Android Application Record, http://developer.android.com/guide/topics/nfc/nfc.html#aar, the resulting Intent to start the app will not be of the action ACTION_NDEF_DISCOVERED, but ACTION_MAIN. This method can be used to launch any app, including apps that do not filter for NFC intents.

NFC guy
  • 10,151
  • 3
  • 27
  • 58