使用前台 Ndef 推送发送 Ndef 消息时收到通知吗?
我正在尝试让两台 Nexus S 设备双向交换 Ndef 消息,而无需点击手机来获取每条单独的消息。我认为启用这两种设备的前台推送和调度不是一个好主意,因为行为可能是不可预测的。我认为实现此目的的一种方法是发起者
- 禁用fg推送和fg调度
- 设置Ndef消息
- 启用fg推送消息
- 发送消息后禁用fg
- 推送启用fg调度
- 通过意图接收响应
- 禁用fg调度
- 转到2
类似地响应者。
唯一的问题是目前的API似乎不支持Step 4,即消息推送成功时收到通知。谁能建议如何做到这一点?或者还有其他实现单点 P2P 的方法吗?
干杯。
I'm trying to get two Nexus S devices to exchange Ndef messages bi-directionally, without having to tap the phones for each individual message. I don't think having both devices' foreground push and dispatch enabled is a good idea as the the behaviour might be unpredictable. I thought one way of acheiving this is for the initiator to
- Disable fg push and fg dispatch
- Set up Ndef message
- Enable fg push with the message
- Disable fg push after message is sent
- Enable fg dispatch
- Receive response via intent
- Disable fg dispatch
- Goto 2
And analogously for the responder.
The only thing is the current API does not seem to support Step 4, i.e. get notified when message is successfully pushed. Can anyone suggest how it could be done? Or any alternative ways of achieving single-tap P2P?
Cheers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无需 NFC 服务通知消息推送即可完成此操作。让您的应用程序从响应消息中隐式推断。这不是您想要的吗?消息到达对等方,但不会通过 NFC 推送到无法理解您消息的设备。
禁用前台推送/前台调度终止通信。
此外,您可以为初始触发器(在接收器处)使用 NDEF_DISCOVERED 过滤器,然后让前台调度接管后续消息。
希望有帮助!
It can be done without the NFC service having to notify message push. Let your application implicitly infer from the response message. Isn't that what you want, the message reaching the peer, and just not pushed over NFC to a device that doesn't understand your message.
Disable Foreground push/Foreground dispatch to terminate communication.
Additionally you can have NDEF_DISCOVERED filter for the initial trigger (at the receiver), then let the Foreground dispatch take over for subsequent messages.
Hope it helps !!