AAR Record in NFC: Where's The Payload?

ぐ巨炮叔叔 提交于 2019-12-03 07:02:10

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

  • 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

  • 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>
    

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

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

From a look at the docs it would seem the use-case is guaranteeing that your application is launched from the NFC event. A second use-case would basically providing a way for the phone to know which app it needs to read a tag.

Couple of questions If you use two records: first normal, second AAR how does the activity get launched? I would expect you'd be started via the tag dispatch intent. Does the AAR intent contain anything that gets you the Tag? I'm thinking you could manua

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!