【问题标题】:I want an android app to open using nfc tag only我希望仅使用 nfc 标签打开一个 android 应用程序
【发布时间】:2012-06-29 06:52:10
【问题描述】:

我正在创建一个使用 nfc 签入的 Andriod 应用程序 假设标签中的网址是“http://examples.com” 我希望只有当我点击该标签时才能打开应用程序。

所以基本上我只会在我的 mainfest 中编辑意图过滤器。这样每次我点击带有http://developer.andriod.com/index.html url 的标签时,应用程序就会打开

   <intent-filter>
           <action android:name="android.nfc.action.NDEF_DISCOVERED" />
                <category android:name="android.intent.category.LAUNCHER" />    
                    <data android:scheme="http"
                    android:host="developer.android.com"
                    android:pathPrefix="/index.html" />                    
    </intent-filter>

【问题讨论】:

  • 请先阅读文档:developer.android.com/guide/topics/connectivity/nfc/…。您的案例在示例中得到了完整的解释。
  • @NFCguy 请检查我编辑的问题?
  • 你需要使用“android.intent.category.DEFAULT”;动作和类别都需要完全匹配。
  • 好的,谢谢你的帮助:)

标签: android nfc


【解决方案1】:

我不熟悉 NFC,但在我看来,您应该执行以下步骤。您应该从 AndroidManifest.xml 意图过滤器中的主要活动中删除:

<intent-filter>
     <action android:name="android.intent.action.MAIN" />
     <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

因此,您的应用程序将不会出现在启动器中。之后,您应该添加一个从 NFC 运行的意图(这里我无法帮助您如何执行此操作)。

【讨论】:

  • 感谢您的尝试 :) 您也提供了帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-05-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多