I have an AlertDialog that can be cancelled (either by back button or clicking outside the dialog). If the dialog is cancelled I need to undo some changes, so I need to control when it’s cancelled.
I tried to create my own subclass of AlertDialog to override some functions (I guess I should override onContextMenuClosed, I wanted to do some tests to find the correct function).
I created my own Builder extending AlertDialog.Builder to create my dialog, and I wanted to override the create() function. I checked the AlertDialog.Builder->create() code, and it uses the variable AlertController.AlertParams P to get some needed data, but that variable is private and I can’t access it from my builder, so I can’t create my dialog.
How can I control if an AlertDialog is cancelled? Using setCancellable(false) is not an option, I want the user to be able to cancel it.
Thanks!
Try setting
setOnCancelListener: