SetCancelable (true) for AlertDialog.Builder does not work as expected on samsung

I recently found that some of the dialogs I have implemented in my application work very well, except for samsung devices.

On every device under test, "setCancelable (true)" dismissed the dialog when clicked outside of it, except for samsung devices.

The Samsung devices I've tested have: Samsung Galaxy S3, S4, and Samsung Galaxy Tab 2.

new AlertDialog.Builder (context) .setCancelable (true) is the exact code.

Anyone else who had this problem? Thank!

+3


source to share


2 answers


I had the same problem, for some reason on some devices like Samsung S3, the dialog doesn't disappear when I click. You can fix this with the setCanceledOnTouchOutside method:

AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
AlertDialog dialog = b.create();
dialog.setCanceledOnTouchOutside(true);
dialog.show();

      



Something like that. I hope to help you.

+11


source


Yes, I suffered from the same issue while testing on Galaxy Grand, but I noticed HTC, Nexus and cyanogenmod behave the same, but samsung behave as part of it.



To fix this problem, you need to maintain boolean flags while the dialog exists / is shown or not.

-1


source







All Articles