如何在android中禁用选择器对话框?

问题描述 投票:0回答:1

我正在使用NFC制作应用程序。

无论何时检测到标签,chooser dialog都会弹出带有Complete action using标题和可能的应用的信息。

我使用SingleTopSingleTask进行了掩盖。但是,它并非始终有效。

似乎我无法真正触摸检测到NFC标签后发生的事情,因为它可以在系统级别使用。不仅在我的应用中。它随处弹出。

我发现了一些自定义选择器对话框的方法,但是,不适用于NFC,因为在我的应用程序中,我从未实现关于createChooser()的任何内容。

我尝试为这样的选择器添加更多代码

val intent = Intent(this, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
// start
val list = arrayListOf<String>()
list.add("[email protected]")
intent.putExtra(Intent.EXTRA_EMAIL, list)
intent.putExtra(Intent.EXTRA_SUBJECT, "Hi")
intent.putExtra(Intent.EXTRA_TEXT, "Hi,This is Test")
pendingIntent = PendingIntent.getActivity(this, 0, Intent.createChooser(intent, "Yaho"), 0)

而且我得到相同的结果。我猜这是因为它是在系统级别控制的。

最佳解决方案是避免在某些特定活动或片段中检测NFC标签并控制选择器对话框。

android android-intent nfc android-pendingintent android-intent-chooser
1个回答
0
投票

使用ForgroundDispatch解决了问题。

© www.soinside.com 2019 - 2024. All rights reserved.