Toast
Toasts are simple message dialogs
val text = "Hello toast!" val duration = Toast.LENGTH_SHORT val toast = Toast.makeText(applicationContext, text, duration) toast.show()
Toast.makeText(this@MainActivity, "Hello Toast!", Toast.LENGTH_SHORT).show()
Alerts
val builder = AlertDialog.Builder(this) builder.setTitle("SocketTimeoutException") builder.setMessage("The server is not responding - Try again later") builder.setPositiveButton(android.R.string.yes) { dialog, which -> Toast.makeText(applicationContext, android.R.string.yes, Toast.LENGTH_SHORT).show() } builder.setNegativeButton(android.R.string.no) { dialog, which -> Toast.makeText(applicationContext, android.R.string.no, Toast.LENGTH_SHORT).show() } builder.show()