Skip to content

Instantly share code, notes, and snippets.

@JuniiiSays
Last active September 12, 2022 15:45
Show Gist options
  • Save JuniiiSays/a11a7aca72e025be91034548864657f2 to your computer and use it in GitHub Desktop.
Save JuniiiSays/a11a7aca72e025be91034548864657f2 to your computer and use it in GitHub Desktop.
Copy Text to Clip Board in Android
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