According to https://developer.android.com/about/versions/11/behavior-changes-11#toasts, Toasts should still work as normal for Android11 (only setView() was deprecated).
Note that text toasts are still allowed; these are toasts created using Toast.makeText() that don't call setView().
However, I cannot get Toast to show for emulators running SDK30 with
compileSdkVersion 30
buildToolsVersion "30.0.3"
and with targetSdkVersion 30
The code used was just a simple
Toast.makeText(getApplicationContext(), "HELLO WORLD", Toast.LENGTH_SHORT).show();
The toast is displayed when I change the targetSdk to 29 (or with devices <SDK30).
Do I need to add any <queries> tags in manifest file for Toasts ? https://developer.android.com/about/versions/11/privacy/package-visibility
I've also tried the following without luck.
- rebooting the emulator Toast not showing in Android Q
- notification ON Toast message not shown
compileSdkVersion 30
andtargetSdkVersion 30
. Moreover, not justapplicationContext
, but any other context (e.g. Activity) won't work either. I recommend to create an issue at the Google Issue Tracker. – MoskvacompileSdkVersion 30
too, but still, the app crashes on my Samsung S10+ whenever a Toast is called (though it runs fine in the Android Studio device emulator) – Jenellejenesia