Warning: Use Nullable Dialog to wrap dialog, to prevent Bad Token etc

Viewed 19

I use custom dialog but get warning:

Use Nullable Dialog to wrap dialog, to prevent Bad Token etc enter image description here TestDialog.kt

class TestDialog(context: Context): Dialog(context) {

    private val viewBinding: DialogTestBinding by lazy { DialogTestBinding.inflate(LayoutInflater.from(context)) }

    init {

        setContentView(viewBinding.root)
        window?.setBackgroundDrawable(ColorDrawable(ContextCompat.getColor(context, R.color.theme_dark_less_transparent)))
    }
}

I know that I can add @SuppressLint("DialogShow") to prevent warning

but how is the corrent way to prevent from it.

0 Answers
Related