Close system dialog when opening the screenfrom the CommonsWare Community archives
At March 16, 2020, 2:28pm, Raptor asked:
I am working on an aplication that has a button to share certain information. When you press that button, a system dialog is being displayed with ways of “sharing” a certain information (you know, the thing with “Complete action using…” and “ALWAYS”, “JUST ONCE” buttons).
The problem is, if you close the screen with this system dialog displayed and re-open the screen, this system dialog is going to be on top of the app PIN/fingerprint unlock screen (it’s a financial app, so it has sensitive data).
I need to find a way to either make this go beneath the app lock screen or dismiss it. I tried to use:
//close any system dialogs when this is displayed sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
in the MainActivity’s onStart() method, but it’s not working.
Do you know of any way to make this work? Thanks!
At March 16, 2020, 2:50pm, mmurphy replied:
What exactly do you mean by this? Do you mean something like: the user presses HOME and then comes back to your app while your process is still running?
Why is this a problem? Once your do the
ACTION_SEND stuff, your app needs to be in position to support that, even if it takes a bit of time for the user to complete the action. If your
ACTION_SEND logic relies upon the fact that the user will always do this very quickly… that doesn’t seem to be a reliable assumption.
I don’t know of a good way of doing that, sorry!
At March 16, 2020, 3:35pm, Raptor replied:
By closing the screen I mean literally pressing the power button on the phone. When you press the power button again (or use the fingerprint to turn it back on) the system dialog will be on top of the application, and data containing user information can leak from there. Don’t know, this is what I have received as a specification from QA
So they requested to hide that dialog or something when you power the phone up again.
At March 16, 2020, 4:37pm, mmurphy replied:
No more than if they had not pressed the power button. By definition, sharing data is an information leak, and pressing the power button is unrelated to that.
I don’t know how you are going to determine that this scenario occurs in a reliable fashion that will not conflict with other things.
However, if you get the timing right, you could try a hack of using
startActivityForResult() (instead of
startActivity()) and then use
finishActivity() to try to get rid of the chooser. Bear in mind that if the user has gone past the chooser, you might not know, and your
finishActivity() call might screw up the sharing.
At March 17, 2020, 12:48pm, Raptor replied:
Hm… how would you do that in practice, though? I mean, let’s say I use startActivityForResult, but where do I use the finish() method? Once I start that Intent, I don’t have any control for what happens next - the system displays the system dialog - where would I put my finish() method call?
EDIT: Nevermind, I saw now that you mentioned finishActivity(), not simply finish().
At March 17, 2020, 1:40pm, Raptor replied:
Your hack worked. Thanks a lot!