【问题标题】:Restoring NFC Tag Behaviour恢复 NFC 标签行为
【发布时间】:2015-05-25 08:58:11
【问题描述】:

我正在创建一个应用程序来检测一些带有 url 的 nfc 标签。当我用 nfc 标签点击手机时遇到问题,我被直接重定向到 url 页面。它没有向我显示应用程序选择器。可能有人最初将 Chorme 设置为默认应用程序,以便在手机遇到此类基于 url 的 NFC 标签时启动。所以我的问题是,是否可以恢复手机的 NFC 设置,以便它会询问我要启动哪个应用程序。

检测 NFC 标签的意图过滤器:

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

意图过滤器来检测网页的启动,我期待我的应用程序+设备上安装的浏览器软件,显示在应用程序选择器中。

<intent-filter>
<action android:name="android.intent.action.VIEW" >  </action>                   <category android:name="android.intent.category.DEFAULT" > </category>
<category android:name="android.intent.category.BROWSABLE" > </category>
<data android:host="www.google.com"
      android:scheme="http" ></data>
</intent-filter>

但没有显示应用选择器,我被直接重定向到网页。

【问题讨论】:

    标签: android nfc


    【解决方案1】:

    我想出了一些适用于这种情况的解决方案:

    对于第一个意图:

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

    第二个意图:

    <intent-filter>
        <action android:name="android.intent.action.VIEW" ></action>
        <category android:name="android.intent.category.DEFAULT" ></category>
        <category android:name="android.intent.category.BROWSABLE" ></category>
        <data android:host="google.com"
          android:scheme="http" ></data>
    </intent-filter>
    

    刚刚更改了对我有用的主机名。

    【讨论】:

      猜你喜欢
      • 2023-03-06
      • 1970-01-01
      • 2021-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多