主屏幕中的 Android 设备作为 NFC 目标

发布于 2024-11-23 20:49:57 字数 137 浏览 2 评论 0原文

当带有 NFC 的 Android 设备位于主屏幕时(当然屏幕处于打开状态,否则 NFC 将无法工作),它是否充当 NFC 目标?如果有,它显示什么数据?

换句话说,我可以为一部手机编写一个可以识别其他手机的应用程序(无需任何专有应用程序)吗?

When an android device with NFC is in home screen (screen on of course, otherwise the NFC won't work), does it act as an NFC target? If so, what data does it show?

In other words, can I write an app for one phone that can identify other phones (without any propriety app)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦里南柯 2024-11-30 20:50:11

请参阅 http://developer.android.com/reference/android/nfc/Tag。 首先,如果任何应用

程序启用了前台调度,这些应用程序将收到通知。就您而言 - 它位于主屏幕,因此这不适用。
之后,它基本上会遍历意图列表以查看是否有任何应用程序对任何标签感兴趣。

换句话说,当屏幕打开并位于主屏幕时,行为就像您有二维码扫描仪始终扫描二维码,并且在扫描相应的代码时浏览器/电话联系人/任何应用程序 - 除了这种情况这是关于 NFC 标签,而不是 QR 码。

手机永远不会充当标签(无源设备),除非在特定的支付模式(Google checkout) - 又名卡模拟模式下。但是,API 并未向开发人员公开此模式。

See http://developer.android.com/reference/android/nfc/Tag.html

First, if any app enabled foreground dispatch, those will get notified. In your case - it's at the home screen, so this does not applies.
Afterwards, it basically goes through the intents list to see if any app is interested at any tag.

In the other word, when the screen is on and at the home screen, the behavior is like you have QR code scanner always scanning for QR code, and Browser/Phone Contact/Whatever app when a corresponding code is scanned - except is this case it's about NFC tag, not QR code.

The phone never act as tag (passive device) except in specific payment mode (Google checkout) - aka card emulation mode. However, the API does not expose this mode for developer.

墨小墨 2024-11-30 20:50:10

您可以通过所谓的 NFC p2p 模式与其他 NFC 手机进行通信(请参阅示例 此处)。在这种情况下,您的应用程序必须安装在两台设备上。

该设备的另一个选项是充当 NFC 标签读取器/写入器 - 但这不是您的应用程序的选项,因为在这种模式下,手机与无源 NFC 标签进行通信。

第三个选项是使手机工作在卡模拟模式。在此模式下,电话模式模拟非接触式智能卡。这对于当前的 Android 操作系统版本 API 来说是不可能的,并且无论如何它仅适用于银行和支付应用程序等。

you can communicate with other NFC phone in the so-called NFC p2p mode (see the example here). In this case must be on both devices your application installed.

The other option for the device is to act as a NFC tag reader/writer - but this is not an option for your application, because in this mode phone communicates with the passive NFC tags.

The third option is to enable the phone to work in card emulation mode. In this mode phone mode emulates the contactless smart card. This is not possible with current Android OS version API and it is anyway intended only for e.g. banking and payment applications.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文