While I'm doing custom toast on my app, I noticed that setView is deprecated.
Does anyone have a solution for this?
toast.setView(customView);
Since setView
is deprecated:
This method was deprecated in API level 30. Custom toast views are deprecated. Apps can create a standard text toast with the
makeText(android.content.Context, java.lang.CharSequence, int)
method, or use aSnackbar
when in the foreground. Starting from AndroidBuild.VERSION_CODES#R
, apps targeting API levelBuild.VERSION_CODES#R
or higher that are in the background will not have custom toast views displayed.
This makes sense Toasts can be displayed on Top of other Apps, some Apps can trick users by creating custom Toasts on Top of other Apps for their advantage even if their App is on the Background. But if your App is in the Foreground your custom Toast will still be shown in all Android Versions.