手机版

Android NFC framework introduction and develop guide(16)

发布时间:2021-06-07   来源:未知    
字号:

Android system NFC framework introduction and develop guide

the Android system checks the first record of an NdefMessage to determine the MIME type or URI of the tag, which is used to create an intent for applications to filter. The following code shows you how to create an AAR:

Beaming NDEF Messages to Other Devices

Android Beam allows simple peer-to-peer data exchange between two Android-powered devices. The application that wants to beam data to another device must be in the foreground and the device receiving the data must not be locked. When the beaming device comes in close enough contact with a receiving device, the beaming device displays the "Touch to Beam" UI. The user can then choose whether or not to beam the message to the receiving device.

Note: Foreground NDEF pushing was available at API level 10, which provides similar

functionality to Android Beam. These APIs have since been deprecated, but are available to support older devices. See enableForegroundNdefPush() for more

information.

You can enable Android Beam for your application by calling one of the two methods:

setNdefPushMessage(): Accepts an NdefMessage to set as the message to beam. Automatically beams the message when two devices are in close enough proximity. setNdefPushMessageCallback(): Accepts a callback that contains a

createNdefMessage() which is called when a device is in range to beam data to. The callback lets you create the NDEF message only when necessary. An activity can only push one NDEF message at a time, so setNdefPushMessageCallback() takes precedence over setNdefPushMessage() if both are set. To use Android Beam, the following general guidelines must be met:

The activity that is beaming the data must be in the foreground. Both devices must have their screens unlocked. You must encapsulate the data that you are beaming in an NdefMessage object. The NFC device that is receiving the beamed data must support the com.android.npp

NDEF push protocol or NFC Forum's SNEP (Simple NDEF Exchange Protocol). The

com.android.npp protocol is required for devices on API level 9 (Android 2.3) to API

Android NFC framework introduction and develop guide(16).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)