Toast not showing in Android Q

南笙酒味 提交于 2021-01-27 03:53:36

问题


Toast does not work in Android Q. Is there any change on Toast? I couldn't find any release note for Toast.
My code is simple.

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    Toast.makeText(this, "onCreate", Toast.LENGTH_SHORT).show()
}

fun onButtonClick(view: View) {
    Toast.makeText(this, "onButtonClick", Toast.LENGTH_SHORT).show()
}

This works fine with Android Pie, but no luck with Android Q.
What happened to Toast??


回答1:


Rebooting device worked for me..




回答2:


As described in this Answer, make sure you haven't disabled notifications for the application. Go to App settings and see that notifications are enabled.



来源:https://stackoverflow.com/questions/56017928/toast-not-showing-in-android-q

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!