发送带有 URI 数据的 Android Beam

发布于 2025-01-03 20:02:46 字数 541 浏览 3 评论 0原文

我正在尝试在一个不会通过 Market 分发的应用程序中实现 Android Beam。我的应用程序的活动和特定网页中的页面之间存在一对一的对应关系。我想要的行为是它尝试打开我的应用程序,如果未安装,则转到相应的网页。该应用已经具有 IntentFilters 来处理这些 URL 的 ACTION_VIEW,我想利用它。我已经尝试使用 NdefRecord.createUri(String uriString),但它总是打开原生 Android 浏览器(如果安装了,它甚至不会转到替代浏览器)。

在我的 ActivityonCreate() 中:

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 技术交流群。

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

发布评论

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

评论(1

π浅易 2025-01-10 20:02:46

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.

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