AAR记录在NFC:哪来的有效载荷? [英] AAR Record in NFC: Where's The Payload?

查看:299
本文介绍了AAR记录在NFC:哪来的有效载荷?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据这个答案,并通过测试,当你使用Android的光束推过包含一个NFC消息验证AAR记录,接收设备将开始在AAR指定的应用程序的 / LAUNCHER 的活动。

According to this answer, and validated by testing, when you use Android Beam to push over an NFC message containing an AAR record, the receiving device will start the MAIN/LAUNCHER activity for the app specified in the AAR.

这是 / LAUNCHER 意图不包含在 NfcAdapter.EXTRA_NDEF_MESSAGES 额外的费用。因此,如果你使用AAR看来,我们通过所有的麻烦去束在数据丢失。

That MAIN/LAUNCHER Intent does not contain the NfcAdapter.EXTRA_NDEF_MESSAGES extra. Hence, the data that we went through all the trouble to beam over appears to be lost if you use AAR.

有一些办法让NFC的消息触发了应用程序在这种情况下要开始了吗?

Is there some way to get the NFC messages that triggered the app to be started in this scenario?

如果答案是否,那么什么是用例AAR的?我能看到它可能是有用的,当所需的应用程序并不接收设备的存在(可以调出Play商店),但一旦应用程序安装后,AAR箔任何试图从一个设备传送数据到另一个,这是有点落后NFC的地步。

And if the answer is "no", then what is the use case of AAR? I can see where it might be helpful when the desired app does not exist on the receiving device (brings up Play Store), but then once the app is installed, AAR foils any attempt to deliver data from one device to the other, which is kinda the point behind NFC.

谢谢!

推荐答案

在回答我的问题,一个配方为获得这个工作(显然)的风险是:

At the risk of answering my own question, one recipe for getting this to work (apparently) is:

  • 有梁发件人使用NFC的消息有两个NFC的记录,第一个包含了一些独特的MIME类型,第二个是在AAR

  • Have the Beam sender use an NFC message with two NFC records, the first containing something for a unique MIME type, the second being the AAR

有梁收件人有一个<意向滤光器> 上响应第一个NFC的记录,如通过活动:

Have the Beam recipient have an <intent-filter> on the activity that responds to the first NFC record, such as via:

    <intent-filter>
        <action android:name="android.nfc.action.NDEF_DISCOVERED"/>

        <category android:name="android.intent.category.DEFAULT"/>

        <data android:mimeType="application/vnd.commonsware.webbeam"/>
    </intent-filter>

如果该应用程序已经存在, NDEF_DISCOVERED 意图将被使用,而接收方可以拿起NFC消息,并从初始记录拉出数据。如果应用程序不存在,AAR会踢,造就了Play商店(无论您的应用程序是通过Play商店或分布不)。

If the app already exists, the NDEF_DISCOVERED Intent will be used, and the recipient can pick up the NFC message and pull out the data from the initial record. If the app does not exist, the AAR will kick in, bringing up the Play Store (whether your app is distributed through the Play Store or not).

这是在开发人员网站了Android梁的例子所显示的配方

This is the recipe shown in the Android Beam example on the developer site.

这篇关于AAR记录在NFC:哪来的有效载荷?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆