Custom toasts from the background are blocked, Android 11 protects users by deprecating custom toast views. For security reasons and to maintain a good user experience, the system blocks toasts that contain custom views if those toasts are sent from the background by an app that targets Android 11.
addCallback() method added in Android R If you want to be notified when a toast (text or custom) appears or disappears.
The most important text in toast API changes that for apps that target Android 11 the getView()
method returns null when you access it, So, ensure to protect your apps from FATAL EXCEPTION, you know what I mean :)
Use snackbars instead if applicable.
It's recommended that you use snackbars instead where possible. If your app's use case prevents you from using snackbars, such as when you need to send the user a message while your app is in the background, you can still use text toasts because they aren't restricted by the new behavior change.
See the official docs for more details on the topic.