I am receiving the above error on my Alert dialog but not sure why or how to fix it. I believe it stems from the function below. Basically when In my app, navigate to the detail fragment then click the send button in the app to share an SMS the app crashes. please take a look at my code. Any help is appreciated.
if (sendSmsStarted && permissionGranted) {
context?.let {
val smsInfo = SmsInfo(
"",
"${currentDog?.dogBreed} bred for ${currentDog?.bredFor}",
currentDog?.imageUrl
)
val diaologBinding: SendSmsDiaologBinding =
DataBindingUtil.inflate<SendSmsDiaologBinding>(
LayoutInflater.from(it),
R.layout.send_sms_diaolog, null, false
)
androidx.appcompat.app.AlertDialog.Builder(it).setView(databinding.root)
.setPositiveButton("Send SMS") { dialog: DialogInterface, which ->
if (!diaologBinding.smsInfo.toString().isNullOrEmpty()) {
smsInfo.to = diaologBinding.smsInfo.toString()
sendSms(smsInfo)
}
}
.setNegativeButton("Cancel") { dialog: DialogInterface, which -> }
.show()
diaologBinding.smsInfo = smsInfo
}
}
}```