【问题标题】:How to avoid detection of NFC tag in android?如何避免在android中检测到NFC标签?
【发布时间】:2019-09-25 03:26:33
【问题描述】:

我正在使用 NFC 制作应用程序。我希望在某些活动或片段中禁用检测或丢弃(无振动、无声音、无应用选择器对话框、无检测通知)。

这可能吗?

只有我在清单中使用SingleTopIntent,如下所示:

Manifests.xml

    <activity
        android:name=".ui.MainActivity"
        android:launchMode="singleTask"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.nfc.action.NDEF_DISCOVERED" />

            <category android:name="android.intent.category.DEFAULT" />

            <data
                android:host="example.com"
                android:scheme="http"/>
        </intent-filter>
    </activity>

MainActivity

val intent = Intent(this, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
pendingIntent = PendingIntent.getActivity(this, 0, intent, 0)

【问题讨论】:

  • 删除此&lt;action android:name="android.nfc.action.NDEF_DISCOVERED" /&gt; 并尝试
  • @MD ???。那我就根本无法在应用中使用NFC功能了。

标签: android nfc android-pendingintent android-intent-chooser


【解决方案1】:

这是因为default wallet。某些设备可以在 NFC 设置中选择 NFC 阅读器。您需要将其关闭。我从未尝试过检测通知并关闭它的解决方案。有NotificationListenerService。如果你想禁用所有通知,你必须研究它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-30
    • 2015-09-22
    • 2016-07-07
    • 1970-01-01
    • 2022-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多