5

I'm testing my app on an Android 11 emulator (Pixel 5 API 31), when I open a toast notification I see the following: enter image description here

Where the toast has a blue default/place holder android icon next to it. How do I replace this placeholder icon with my own icon?

Older versions of android do not show any icon with the toast message.

My app already has a custom Launcher Icon, Notification Icon and Action Bar and Tab Icons. So it appears it's not inheriting from this, but I can't work out what I need to add or change to replace it with either my own icon or remove it.

This is my java code to launch a toast if required:

   Toast.makeText(getContext(),getString(R.string.crashTurnedOn),Toast.LENGTH_SHORT).show();

Thank you for any help.

J34245
  • 300
  • 2
  • 12
  • 1
    You need to create custom toast view. Check out the `getView()` https://developer.android.com/reference/android/widget/Toast#getView() method. – Chhatrasal Singh Bundela Aug 22 '21 at 17:24
  • 1
    The getView() method is now deprecated with Android 11. It would be great to get an answer to this question; I'm experiencing it with Android 12 (API 31). – shagberg Oct 15 '21 at 18:03
  • Checkout https://stackoverflow.com/questions/69630124/how-to-configure-toast-icon-in-android-12 – speller Nov 09 '21 at 15:39
  • @ChhatrasalSinghBundela so, aren't there way possible to customize a toast message on API level 30 and later, right? Por instance, aren't there how to remove the icon anymore? – Jorge Luiz Jul 03 '22 at 23:18

0 Answers0