When user press home button onStop() method is called and system takes screenshot which can be seen among open applications when user press and hold home button(on android phones). My question is how to prevent sensitive data to be visible to anybody who can take a phone and press and hold home button? Imagine, application(activity) presents a preview of secret document and user press home button(maybe somebody just approached to the user and he doesn't want to anybody see his secret document). However, anybody who takes a phone after that can press and hold home button and see some sensitive data.
I tried to hide view onPause and/or onStop but that doesn't work. So, how to remove current visible view before system takes screenshot after onStop?
Thanks.
My question is how to prevent sensitive data to be visible to anybody who can take a phone and press and hold home button?
Quoting myself:
However, for the user’s benefit, there may be reasons to block screenshots from certain of your activities. To do that, use
FLAG_SECURE:
public class FlagSecureTestActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(LayoutParams.FLAG_SECURE,
LayoutParams.FLAG_SECURE);
setContentView(R.layout.main);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With