I have an alert dialog, I want to make non cancellable, if the user clicks back button on the device, the dialog is gone. how do i stop it from doing that.
I have added setCancelable(false) but it is not working.
Any thoughts on how to fix this please
Here is my code.
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
app.bus.post(ScreenDimEvent(false))
val builder = AlertDialog.Builder(activity)
val inflater = activity!!.layoutInflater
@SuppressLint("InflateParams")
val inflatedView = inflater.inflate(R.layout.dialog_quality_control, null)
ButterKnife.bind(this, inflatedView)
builder
.setView(inflatedView)
.setCancelable(false)
.setTitle(getString(R.string.quality_control) + " - " + qualityControlCheck.name)
.setPositiveButton(R.string.fuel_order_signature_dialog_save) { dialog, id ->
validator.validate()
}
presenter.setView(this)
presenter.init(fuelOrderId, qualityControlCheck)
dialog = builder.create()
dialog.setCancelable(false)//TRIED THIS BUT DID NOT WORK
dialog.setCanceledOnTouchOutside(false)
return dialog
}