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文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219