我想通过 NFC 卡启动特定的 Android 应用程序。我不想让 android 询问我应该打开哪个应用程序。它应该立即打开我的应用程序。我怎么能这么做呢?
我已经尝试使用 MIME-Types
但它不起作用。我可以指定自己的 MIME-Type
吗?是否可以检查特定文本的 MIME-Type
text/plain( Intent 过滤器?)?
例如:我希望我的应用程序在 NFC 卡存储了特定文本(如“测试”或其他内容)时启动。
我们的想法是它应该适用于所有常见的移动操作系统。因此 Android 应用程序链接将无法工作。
最佳答案
您可以创建自己的应用程序 mimeType。
You could create a custom mimeType in your NDEF message and then create an intent-filter which matches it exactly. This would mean your app would be launched as it is the most specific filter.
Example:
<intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="application/vnd.com.my.app.package.customString" /> </intent-filter>
取 self 之前提供的示例:https://stackoverflow.com/a/27397938/3312868
关于android - 使用 NFC 启动特定的 Android 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38740153/