Skip to content

Toast#getView() was deprecated on Android 11 and it returns null #16

@tateisu

Description

@tateisu
/**
 * Return the view.
 *
 * <p>Toasts constructed with {@link #Toast(Context)} that haven't called {@link #setView(View)}
 * with a non-{@code null} view will return {@code null} here.
 *
 * <p>Starting from Android {@link Build.VERSION_CODES#R}, in apps targeting API level {@link
 * Build.VERSION_CODES#R} or higher, toasts constructed with {@link #makeText(Context,
 * CharSequence, int)} or its variants will also return {@code null} here unless they had called
 * {@link #setView(View)} with a non-{@code null} view. If you want to be notified when the
 * toast is shown or hidden, use {@link #addCallback(Callback)}.
 *
 * @see #setView
 * @deprecated Custom toast views are deprecated. Apps can create a standard text toast with the
 *      {@link #makeText(Context, CharSequence, int)} method, or use a
 *      <a href="{@docRoot}reference/com/google/android/material/snackbar/Snackbar">Snackbar</a>
 *      when in the foreground. Starting from Android {@link Build.VERSION_CODES#R}, apps
 *      targeting API level {@link Build.VERSION_CODES#R} or higher that are in the background
 *      will not have custom toast views displayed.
 */
@Deprecated
@Nullable public View getView() {
    return mNextView;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions