88.6 Adding a Toast Convenience Method
At various points throughout the code in this example the app will be designed to display information to the user via Toast messages. Rather than repeat the same Toast code multiple times, a convenience method named notifyUser() will be added to the main activity. This method will accept a single String value and display it to the user in the form of a Toast message. Edit the MainActivity.kt file now and add this method as follows:
.
.
import android.widget.Toast
.
.
private fun notifyUser(message: String) {
Toast.makeText(this,
message,
Toast.LENGTH_LONG).show()
}