androidtoastandroid-toast

Toast Message Not Shown when Android API is 31 or Above


I updated my Android app to API 31 recently because of the new policy about "Target API level requirements for Google Play apps" here: https://support.google.com/googleplay/android-developer/answer/11926878?hl=en

Since I update the API to 31, I found that the Toast message is not shown when I turn off my notification.

Is there any way to show Toast messages when I turn off the notification on my phone or my app?

I know that the Toast message works correctly when I turn on my notification on my phone/app.

But I still want to figure out the solution to solve this problem.

Sorry for my poor English.

Thank you guys.


Solution

  • Just further reply your question here.

    Searching Toast logic from the AOSP source code, it will check the notification enabled or not to decide whether to show the Toast.

    AOSP Website REF: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/services/core/java/com/android/server/notification/NotificationManagerService.java Line: 3330


    So if you have the ability to deploy the ROM by yourself, you can definitely change the AOSP code there.

    And if you are just a normal app developer, you shall follow the strict rules defined.

    Either replace your Toast with other implementation (e.g., SnackBar) or show a warning when you determine users have disabled the feature.