基于标签的NFC监听器触发
我正在研究 NFC 及其使用,我首先通过为 Android 创建 NFC 应用程序进行简单的概念验证。当标签被扫描时,它会发送带有标签 ID 的 REST 请求,以查看它是否已注册到服务,如果是,则下载内容并在手机上播放。
问题是标签的 ID 是连续的,要求存储一些唯一的随机信息,以避免可能的复杂性和安全问题。问题是,数据应该是什么?这个问题有一些标准吗?
这个想法是存储x,y
,其中x
是触发器标识符,y
是一个随机的唯一数字。这行得通吗?可以根据x
值启动自定义活动吗?
感谢任何帮助和参考。会有蛋糕。
I am doing a research on NFC and its use, I've started with a simple proof of concept by creating an NFC application for Android. When tag is scanned, it sends REST request with tag's ID to see whether it is registered with the service, and if is, content is downloaded and played on the phone.
The problem is tags' ID are sequential, the requirement is to have some unique random information stored to avoid possible complications and security issues. The question is, what should the data be? Is there some standard on the subject?
The idea is to store x,y
where x
is trigger identifier and y
is a random unique number. Would this work? Can custom activity be started based on x
value?
Any help and references are appreciated. There will be cake.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您肯定想查看此页面,它描述了新检测到的标签的最新调度过程: http://developer.android.com/reference/android/nfc/Tag.html。现在,如果您的标签检测应用程序预计在扫描标签时运行,情况就会有所不同。如果它位于前台,您可以确定您的活动将首先破解扫描的标签,无论检测到什么标签。如果您的应用尚未运行但已安装在设备上,则 AndroidManifest.xml 中的意图过滤器将决定您的应用是否有机会收到检测到的标签的通知。以前,所有标签数据都放入发送的 Intent 的 extra 中。但在 2.3.3 中,如果标签的第一个 NDEF 记录中有 URI,并且标签是 URI 或 SmartPoster,则该 URI 会被放入意图的数据字段中,该字段将在与意图过滤器匹配时使用。如果标记是 MIME_TYPE 标记,则 mime 类型将放入意图的类型字段中。因此,如果您使用应用程序正在寻找的自定义 URI 或自定义 MIME 类型,您应该始终收到有关标签的通知(除非另一个应用程序位于前台并请求了所有标签)。
You definitely want to check out this page, which describes the latest dispatch process for a newly-detected tag: http://developer.android.com/reference/android/nfc/Tag.html. It now makes a difference if your tag-detecting app is expected to be running at the time the tag is scanned. If it's in the foreground, you can be sure that your activity is going to get first crack at a scanned tag, whatever tag is detected. If your app is not already running but is installed on the device, then the intent filter(s) in your AndroidManifest.xml will dictate whether or not your app has a chance at being notified of the detected tag. Previously, all tag data was put into the extras of the intent that was sent out. But in 2.3.3, if there is a URI in the tag's first NDEF record, and the tag is URI or SmartPoster, that URI gets put into the intent's data field, which will be used when matching against intent filters. If the tag is a MIME_TYPE tag, the mime type is put into the intent's type field. Therefore, if you use a custom URI or custom MIME type that your app is looking for, you should always get notified of your tags (unless another app is in the foreground and has requested all tags).
我有一个为 NFC(phonegap)开发的插件,我只需使用:
它就像一个魅力。
I have a plugin I developed for NFC (phonegap) and I simply use:
And it works like a charm.
我使用 FakeTagsActivity 将 NDEF 消息加载到 NFCAdapter 中。我通过意图传递 URI/文本消息。但无法使用以下意图过滤器启动 TagViewer 活动。
I used the FakeTagsActivity to load NDEF message into NFCAdapter. I am passing the URI/text message through an intent. But unable to launch the TagViewer activity with following intent filter.