Home » Android » android – Toast is not shown on Samsung Galaxy S3 (latest update 4.1.2)

android – Toast is not shown on Samsung Galaxy S3 (latest update 4.1.2)

Posted by: admin June 15, 2020 Leave a comment

Questions:

I have a toast that is displayed in the following way:

Toast.makeText(context, "The message", Toast.LENGTH_LONG).show();

I am absolutely certain I am displaying the toast from the UI thread, and I can add that it worked fine for many devices including older updates of the Galaxy S3, but after the latest update none of my toasts are being displayed.

Has anyone else experienced this and has a solution?

How to&Answers:

In newer Android phones there is a “Show notifications” checkbox in App Settings and for some reason if notifications are disabled it also disables Toasts. The issue has been reported here:

http://code.google.com/p/android/issues/detail?id=35013

But looking on the source code:

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/services/java/com/android/server/NotificationManagerService.java

it seems like it might be intentional:

Line 114:

private static final boolean ENABLE_BLOCKED_TOASTS = true;

Lines 693-707:

final boolean isSystemToast = ("android".equals(pkg));
if (ENABLE_BLOCKED_TOASTS && !isSystemToast && !areNotificationsEnabledForPackageInt(pkg))     {
    Slog.e(TAG, "Suppressing toast from package " + pkg + " by user request.");
    return;
}

Answer:

Since the OP hasn’t been around in the past 24 hours, I’ll post the solution that was found on a thread on the android-developers Google Group.

The problem was that the option to Show Notifications for this app was unchecked in the Settings (this is possible in newer versions of Android). This not only prevents the showing of notifications in the notification bar, but also prevents the display of toasts.

A bug for this has been opened here.