This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val clipboardManager = context.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager | |
// When setting the clip board text. | |
val clipData = ClipData.newPlainText(/* label = */ "Sample copy data",/* text = */ context.getString(R.string.clip_preview)) | |
.apply { | |
description.extras = PersistableBundle().apply { | |
// only available for Android13 or higher | |
putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true) | |
// use raw string for older versions | |
// android.content.extra.IS_SENSITIVE | |
} | |
} | |
clipboardManager.setPrimaryClip(clipData) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment