带有 URL 打开浏览器的 Android NFC 标签,而不是我的应用程序 [英] Android NFC tag with URL opening browser, not my app

查看:150
本文介绍了带有 URL 打开浏览器的 Android NFC 标签,而不是我的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照说明设置 NFC 以在 Android 上启动我的应用.标签中的第一条记录是我网站的网址.前任.例子.com

AndroidManifest.xml 文件具有以下意图过滤器:

<action android:name="android.nfc.action.NDEF_DISCOVERED"/><data android:host="example.com" android:scheme="http"/><category android:name="android.intent.category.DEFAULT"/></意图过滤器>

但无论出于何种原因,当我扫描标签时,打开的是 android 浏览器,而不是我的应用程序.nfc 的 Android 文档似乎没有任何额外的步骤

我希望您曾经告诉 Chrome 打开 http://example.com 标签或所有 URL 标签,现在Chrome 会在您的应用启动之前获取意图.

如果通过重置所有应用首选项解决了这个问题.设置 -> 设备 -> 应用 -> 菜单 -> 重置应用首选项"请参阅 https://support.google.com/nexus/answer/6271667?hl=zh

重置首选项后,当我扫描标签时,Android 再次提示我选择一个应用程序.我总是选择使用 NFCLaunch(我的应用程序)完成操作.现在带有 http://example.com 的标签打开我的应用程序,但其他带有 http://android.com 仍将在 Chrome 中打开.

另一种选择是:禁用 Chrome,扫描标签,选择应用,重新启用 Chrome.

I followed instructions to setup NFC to launch my app on Android. The first record in the tag is a url to my website. ex. example.com

The AndroidManifest.xml file has the following intent filter:

<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED" />
    <data android:host="example.com" android:scheme="http" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

But for whatever reason when I scan the tags, the android browser opens, not my app. Android documentation for nfc doesn't appear to have any additional steps https://developer.android.com/guide/topics/connectivity/nfc/nfc.html

For what it's worth, I'm using Apache Cordova and the phonegap-nfc plugin.

解决方案

Your intent filter looks good and works a sample app I wrote. I get prompted to open the tag with my app or Chrome.

I expect at one point you told Chrome to open http://example.com tags or all URL tags and now Chrome grabs the intent before your app can launch.

If fixed this by resetting all app preferences. Settings -> Device -> Apps -> Menu -> "Reset App Preferences" See https://support.google.com/nexus/answer/6271667?hl=en

After resetting the preference Android prompted me again to choose an app when I scanned the tag. I chose complete action using NFCLaunch (my app) always. Now tags with http://example.com open my app but other tags with http://android.com will still open in Chrome.

Another option is to: disable Chrome, scan the tag, choose the app, re-enable Chrome.

这篇关于带有 URL 打开浏览器的 Android NFC 标签,而不是我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆