如何摆脱或隐藏“NFC 检测通知”和“使用弹出窗口完成操作”?
How to get rid of or hide `NFC detection notification` and `complete action using pop up`?
我制作了一个使用 NFC 读取的应用程序。
我使用 singleTask
来避免重复的屏幕弹出窗口。
<activity
android:name=".view.main.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>
我用FLAG_ACTIVITY_SINGLE_TOP
val intent = Intent(this, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) // or?? and??
pendingIntent = PendingIntent.getActivity(this, 0, intent, 0)
我用Hauwei Mate 20 Pro
。并且它不断得到 NFC detection Notificaiton
,有时得到 complete action using pop up
。
我怎样才能避免这种情况?
你用过吗enableForegroundDispatch(this, pendingIntent, writeTagFilters, null);
在 onResume()
和 nfcAdapter.disableForegroundDispatch(this);
ìn onPause()
?
我制作了一个使用 NFC 读取的应用程序。
我使用 singleTask
来避免重复的屏幕弹出窗口。
<activity
android:name=".view.main.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>
我用FLAG_ACTIVITY_SINGLE_TOP
val intent = Intent(this, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) // or?? and??
pendingIntent = PendingIntent.getActivity(this, 0, intent, 0)
我用Hauwei Mate 20 Pro
。并且它不断得到 NFC detection Notificaiton
,有时得到 complete action using pop up
。
我怎样才能避免这种情况?
你用过吗enableForegroundDispatch(this, pendingIntent, writeTagFilters, null);
在 onResume()
和 nfcAdapter.disableForegroundDispatch(this);
ìn onPause()
?