gpt4 book ai didi

java - 可显示的 Toast 数量有限制吗?

转载 作者:行者123 更新时间:2023-12-01 19:38:27 30 4
gpt4 key购买 nike

在 MainActivity 中,我需要显示 getApplicationContext().fileList() 返回的所有文件,但只会显示大约前 50 个 Toast。

有一些限制吗?

String[] fileList = getApplicationContext().fileList();

Toast.makeText(getApplicationContext(), fileList.length + " files", Toast.LENGTH_LONG).show();

for (String fileName : fileList)
{
Toast.makeText(getApplicationContext(), fileName, Toast.LENGTH_LONG).show();
}

谢谢

最佳答案

2023 年 2 月更新

一个新的limit Android 12 中添加了 5 个排队 toast,preventing to queue too many toasts .

// To limit bad UX of seeing a toast many seconds after if was triggered.
static final int MAX_PACKAGE_TOASTS = 5;
if (count >= MAX_PACKAGE_TOASTS) {
Slog.e(TAG, "Package has already queued " + count
+ " toasts. Not showing more. Package=" + pkg);
return;
}

还有previous limit of 50 toasts在 Android 10 中更改为 25。

static final int MAX_PACKAGE_NOTIFICATIONS = 25;

原始答案

是的,Toasts 会排队,并且限制为 50 个 Toasts,您可以在 NotificationManagerService 中查看检查情况。类

if (count >= MAX_PACKAGE_NOTIFICATIONS) {
Slog.e(TAG, "Package has already posted " +
+ " toasts. Not showing more. Package=" + pkg);
return;
}

并且 MAX_PACKAGE_NOTIFICATIONS 声明为

static final int MAX_PACKAGE_NOTIFICATIONS = 50;

关于java - 可显示的 Toast 数量有限制吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56514996/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com