0

In Android API 33, when you copy something to clipboard, a special bar appears:

The clipboard bar

If the copied data is sensitive, you can set ClipDescription.EXTRA_IS_SENSITIVE to true for the clip:

        PersistableBundle persistableBundle = new PersistableBundle();
        persistableBundle.putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true);
        clip.getDescription().setExtras(persistableBundle);

As a result, the copied data becomes hidden:

Hidden text in the clipboard bar

However, when you click the share button on that bar or use the copied text in another app, the text is revealed:

Sharing copied text using the clipboard bar

Or

Sensible data is visible on the top of the soft keyboard

The question is how to hide sensitive data in this scenario?

Oleh Romanenko
  • 289
  • 1
  • 11
  • It's behaving exactly as doc specifies. If user copies sensitive data and decides to share or paste it in another app there isn't much that you can do aside from preventing copying in the first place. – Pawel Jun 04 '23 at 19:57
  • Well, if nothing can be done, it looks like a bug to me. Hiding the data from the bar but revealing it from the same bar immediately in the next step is a bit strange behavior. – Oleh Romanenko Jun 04 '23 at 20:06
  • The sense in hiding the data is to prevent others who can view the screen but not access the phone from getting the sensitive data. – Robert Jun 04 '23 at 20:58
  • @Robert, that's what I'm talking about: The sense in hiding the data is to prevent others who can view the screen. See my image 2 - the data is hidden, then I click the Share button, and on the next image that data is revealed. I need the data to be hidden all the way from my app to where it will be pasted – Oleh Romanenko Jun 04 '23 at 21:11
  • If you need that, you need to not support copy paste, and roll your own only within your app. – Gabe Sechan Jun 05 '23 at 03:30
  • Sensitive data should not be shared, if the user does it anyway then this is the user's choice. – Robert Jun 05 '23 at 06:50

0 Answers0