Last active
September 12, 2022 15:45
-
-
Save JuniiiSays/a11a7aca72e025be91034548864657f2 to your computer and use it in GitHub Desktop.
Copy Text to Clip Board in Android
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
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); | |
ClipData clip = ClipData.newPlainText(label, text); | |
clipboard.setPrimaryClip(clip); | |
// Make sure you have imported android.content.ClipboardManager and NOT android.text.ClipboardManager. Latter is deprecated. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment