In the MainActivity I need to show all files returned by getApplicationContext().fileList()
but only about the first 50 Toast will be displayed.
There is some limit for that?
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();
}
Thanks
A new limit of 5 queued toasts was added in Android 12, 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;
}
Also the previous limit of 50 toasts was changed to 25 in Android 10.
static final int MAX_PACKAGE_NOTIFICATIONS = 25;
Yes, toasts are queued and there is a limit of 50 toasts, you can see the check for it in NotificationManagerService
class
if (count >= MAX_PACKAGE_NOTIFICATIONS) {
Slog.e(TAG, "Package has already posted " +
+ " toasts. Not showing more. Package=" + pkg);
return;
}
And MAX_PACKAGE_NOTIFICATIONS
is declared as
static final int MAX_PACKAGE_NOTIFICATIONS = 50;