Created
June 10, 2020 17:40
-
-
Save mdavalos1993/ecec117463a25796832d094b79a1064e to your computer and use it in GitHub Desktop.
Copy text to Clipboard in Android - Kotlin
This file contains hidden or 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
private fun copyToClipboard(text: String){ | |
val clipboard = requireActivity().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager | |
val clip = ClipData.newPlainText(UUID.randomUUID().toString(), text) | |
clipboard.setPrimaryClip(clip) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment