Skip to content

Instantly share code, notes, and snippets.

@mdavalos1993
Created June 10, 2020 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdavalos1993/ecec117463a25796832d094b79a1064e to your computer and use it in GitHub Desktop.
Save mdavalos1993/ecec117463a25796832d094b79a1064e to your computer and use it in GitHub Desktop.
Copy text to Clipboard in Android - Kotlin
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