Recently my smartphone (Google Pixel 3) got an update from Android 11 to 12. Afterwards, I wanted to adapt my app Sensor Recording accordingly. So I made some changes in "build.gradle":
compileSdkVersion 31 // 30 before
defaultConfig {
targetSdkVersion 31 // 30 before
…
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.0' // 1.3.1 before
…
}
Everything was working correctly. However, I detected that the Toast messages were different now: They include a useless icon, and – even worse – the text message was truncated.
Before – with SdkVersion 30
And after – with SdkVersion 31
Both Toast are generated with the same code. But in the new version, the important parts of the text are missing. How can I get back the old Toast behaviour?
If your app targets Android 12 (API level 31) or higher, toast is limited to two lines of text and shows the application icon next to the text. Be aware that the line length of this text varies by screen size, so it's good to make the text as short as possible.
You can useSnackbar
. – Major