Shahid Thaika
Shahid Thaika

Reputation: 2305

Problems implementing the new sensitive clipboard code in Android SDK 13

Has anyone else tried to mark their clipboard copied data as sensitive as per the following recommendation?

https://developer.android.com/about/versions/13/features/copy-paste

clipData.apply {
    description.extras = PersistableBundle().apply {
        putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true)
    }
}

When I tried to do so, I don't find a clipData.apply method.

enter image description here

How can I set the sensitivity settings in an android app Java code?

Upvotes: 2

Views: 973

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007296

apply() is a Kotlin scope function. You appear to be programming in Java, so the Kotlin syntax will not work for you.

By eyeball, the Java equivalent would be:

PersistableBundle extras = new PersistableBundle();

extras.putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true);

clipData.getDescription().setExtras(extras);

Upvotes: 2

Related Questions