I know it’s pretty straightforward but I haven’t found any example out there of using the clipboard from Android Applications. So for beginners like me, here is an example of how to copy and paste some text using ClipboardManager object.

This is the Copy button code:
// Copy EditCopy text to the ClipBoard
private void copyToClipBoard()
{
ClipboardManager ClipMan = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipMan.setText(editCopy.getText());
}
and the Paste button source:
// Paste ClipBoard Text to EditPaste
private void pasteFromClipBoard()
{
ClipboardManager ClipMan = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
editPaste.setText(ClipMan.getText());
}
Simple, right?
By the way, editPaste and editCopy are both EditText class objects. In case you need it, the whole project can be downloaded from my GitHub repository.
_______________________________________________________________





