8

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?

Suman
  • 9,221
  • 5
  • 49
  • 62
Tobias Lindberg
  • 152
  • 1
  • 11

2 Answers2

11

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;
}
devconsole
  • 7,875
  • 1
  • 34
  • 42
Tobias Lindberg
  • 152
  • 1
  • 11
5

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.

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195