Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toast not showing in Android Q

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??

like image 893
khcpietro Avatar asked May 07 '19 07:05

khcpietro


People also ask

How do you show Toast messages on android?

Display the created Toast Message using the show() method of the Toast class. The code to show the Toast message: Toast. makeText(getApplicationContext(), "This a toast message", Toast.

How do I show Toast in center of screen?

A standard toast notification appears near the bottom of the screen, centered horizontally. You can change this position with the setGravity(int, int, int) method. This accepts three parameters: a Gravity constant, an x-position offset, and a y-position offset.

What is Toast in Android Studio?

A toast provides simple feedback about an operation in a small popup. It only fills the amount of space required for the message and the current activity remains visible and interactive. Toasts automatically disappear after a timeout.


1 Answers

Rebooting device worked for me..

like image 108
khcpietro Avatar answered Oct 05 '22 21:10

khcpietro