CarToast


class CarToast


A message to show to the user for a short period of time.

Summary

Constants

const Int

Show the Toast view for a long period of time.

const Int

Show the Toast view for a short period of time.

Public functions

java-static CarToast
makeText(carContext: CarContext, text: CharSequence, duration: Int)

Creates and sets the text and duration for the toast view.

java-static CarToast
makeText(carContext: CarContext, textResId: @StringRes Int, duration: Int)

Creates and sets the text and duration for the toast view.

Unit
setDuration(duration: Int)

Sets how long to show the toast for.

Unit

Sets the text for the toast.

Unit
setText(textResId: @StringRes Int)

Sets the text for the toast.

Unit

Shows the toast with the specified text for the specified duration.

Constants

LENGTH_LONG

Added in 1.0.0
const val LENGTH_LONG = 1: Int

Show the Toast view for a long period of time.

See also
setDuration

LENGTH_SHORT

Added in 1.0.0
const val LENGTH_SHORT = 0: Int

Show the Toast view for a short period of time. This is the default duration.

See also
setDuration

Public functions

makeText

Added in 1.0.0
java-static fun makeText(carContext: CarContext, text: CharSequence, duration: Int): CarToast

Creates and sets the text and duration for the toast view.

Parameters
text: CharSequence

the text to show

duration: Int

how long to display the message. Either LENGTH_SHORT or LENGTH_LONG

Throws
java.lang.NullPointerException

if either the carContext or the text are null

makeText

Added in 1.0.0
java-static fun makeText(carContext: CarContext, textResId: @StringRes Int, duration: Int): CarToast

Creates and sets the text and duration for the toast view.

Parameters
textResId: @StringRes Int

the resource id for the text to show. If the textResId is 0, the text will be set to empty

duration: Int

how long to display the message. Either LENGTH_SHORT or LENGTH_LONG

Throws
java.lang.NullPointerException

if carContext is null

setDuration

Added in 1.0.0
fun setDuration(duration: Int): Unit

Sets how long to show the toast for.

Parameters
duration: Int

how long to display the message. Either LENGTH_SHORT or LENGTH_LONG

setText

Added in 1.0.0
fun setText(text: CharSequence): Unit

Sets the text for the toast.

Throws
java.lang.NullPointerException

if text is null

setText

Added in 1.0.0
fun setText(textResId: @StringRes Int): Unit

Sets the text for the toast.

Parameters
textResId: @StringRes Int

the resource id for the text. If the textResId is 0, the text will be set to empty

show

Added in 1.0.0
fun show(): Unit

Shows the toast with the specified text for the specified duration.

Throws
androidx.car.app.HostException

if the remote call fails