当应用程序在ICS通过NFC开始检测应用程序、ICS、NFC

2023-09-07 09:08:48 作者:错觉

ICS引入的可能性分享通过Android Beam功能使用NFC的应用程序,而据我的理解,如果一个应用程序打开的deviceA它会自动在deviceB启动(如果它已经安装在其上,否则市场应用将开)时,设备足够接近,并且用户触控光吧。有没有一种方法,发射活动里面,检测是否已经因为NFC的消息,因为用户交互?

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?

推荐答案

在情况下,Android Beam功能(或NDEF)消息包含一个Android应用程序记录,的 http://developer.android.com/guide/topics/nfc/nfc.html#aar ,由此产生的意图,开始将应用程序不是动作ACTION_NDEF_DISCOVERED,但ACTION_MAIN的。这种方法可以用来发射的任何的应用程序,包括不为NFC意图过滤的应用程序。

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.