发送带有 URI 数据的 Android Beam
我正在尝试在一个不会通过 Market 分发的应用程序中实现 Android Beam。我的应用程序的活动和特定网页中的页面之间存在一对一的对应关系。我想要的行为是它尝试打开我的应用程序,如果未安装,则转到相应的网页。该应用已经具有 IntentFilters
来处理这些 URL 的 ACTION_VIEW
,我想利用它。我已经尝试使用 NdefRecord.createUri(String uriString)
,但它总是打开原生 Android 浏览器(如果安装了,它甚至不会转到替代浏览器)。
在我的 Activity
的 onCreate()
中:
NdefMessage msg = new NdefMessage(new NdefRecord[] { NdefRecord.createUri(getAppUri()) });
NfcAdapter.getDefaultAdapter(this).setNdefPushMessage(msg, this);
I'm trying to implement Android Beam in an app that will not be distributed through Market. There is a one-to-one correspondence between my app's activities and pages in a particular web page. The behavior I would like is for it to attempt to open my app, and if it is not installed to go to the corresponding web page. The app already has IntentFilters
to handle the ACTION_VIEW
for those URLs, and I'd like to leverage that. I already tried using NdefRecord.createUri(String uriString)
, but it always opens the stock Android browser (It won't even go to alternative browsers if installed).
In the onCreate()
of my Activity
:
NdefMessage msg = new NdefMessage(new NdefRecord[] { NdefRecord.createUri(getAppUri()) });
NfcAdapter.getDefaultAdapter(this).setNdefPushMessage(msg, this);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Android Beam Intents 将操作设置为 ACTION_NDEF_DISCOVERED(而不是 ACTION_VIEW),因此您应该对其进行过滤。
Android Beam Intents have the action set to ACTION_NDEF_DISCOVERED (not ACTION_VIEW), so you should filter for that instead.