Toasts
Use Coryn.acceptToast to track a Toast for UI captures. By default it also calls Android's Toast.show(). Every accepted Toast is represented in replay by the text you supply in a simple SDK layout, including Toasts with custom Views.
Call Coryn.init first and invoke these APIs on the main thread. All overloads return the Android Toast so you can cancel it.
Standard text Toasts
- Kotlin
- Java
Coryn.acceptToast(context, "Saved successfully", Toast.LENGTH_SHORT)
Coryn.acceptToast(context, R.string.saved_successfully, Toast.LENGTH_LONG)
Coryn.acceptToast(context, "Saved successfully", Toast.LENGTH_SHORT);
Coryn.acceptToast(context, R.string.saved_successfully, Toast.LENGTH_LONG);
The optional final show argument defaults to true in Kotlin and Java. Do not call .show() again when using that default.
Configured and custom Toasts
Configure the Toast before accepting it. Pass the same context used to create it, including its display and configuration. The required text argument is the replay message; it does not change the actual Android Toast.
val toast = Toast(context).apply {
view = customToastView
duration = Toast.LENGTH_LONG
setGravity(Gravity.TOP or Gravity.CENTER_HORIZONTAL, 0, 80)
}
Coryn.acceptToast(context, toast, "Saved successfully")
Coryn never captures or redraws the custom layout. Its colors, graphics, placement and View/Composable hiding declarations do not affect the replay representation. Replay uses only the supplied text and SDK styling.
Android deprecated custom Toast Views in API 30. They can still appear while the app is foregrounded. On Android 11+, apps targeting API 30+ cannot show custom Toasts from the background. Coryn follows actual platform visibility rather than assuming that a requested Toast was shown.
Sensitive Toast content and manual showing
Toast replay text is a separate source. Hiding a View or Composable does not hide text supplied to acceptToast, including hiding declarations inside a custom Toast.
If a Toast or any part of its custom layout contains content that must be hidden from replay, supply safe replacement text, pass show = false, and show the real Toast yourself. Do not pass the sensitive message as the replay text. An empty replay message avoids including any message text.
- Kotlin
- Java
val toast = Toast.makeText(context, "Payment to $recipient completed", Toast.LENGTH_LONG)
// Register a safe replay message. Coryn does not call toast.show().
Coryn.acceptToast(context, toast, "Payment completed", show = false)
toast.show()
Toast toast = Toast.makeText(context, "Payment to " + recipient + " completed", Toast.LENGTH_LONG);
// The explicit false flag registers tracking without showing the Toast.
Coryn.acceptToast(context, toast, "Payment completed", false);
toast.show();
Both show = true and show = false use the same safe replay representation. With false, you must show the Toast yourself before it can appear in replay. Register the configured instance before showing it, then show it once. Do not replace its View, mutate its message or reuse it after registration.
The text and resource overloads also accept show = false and return an unshown Toast:
val toast = Coryn.acceptToast(context, "Saved", Toast.LENGTH_SHORT, show = false)
toast.show()
Visibility and cancellation
val toast = Coryn.acceptToast(context, "Uploading…", Toast.LENGTH_LONG)
toast.cancel()
Toasts appear in replay only while shown, including when Android queues them or extends their duration for accessibility. Expiry or cancellation removes them.
SDK styling, line wrapping and animation can differ from Android or the device manufacturer. Toasts are added to UI captures; this feature does not create a Toast State/Event or add Toast messages to Screen Text.
See Privacy Masking and Android's Toast API.