Set text and get text from clipboard

AndroidClipboard

Android Problem Overview


In Android, I need some code to "get text" and "set text" in the clipboard.

For example I want to put "asd" in memory and after that paste it from clipboard.

Android Solutions


Solution 1 - Android

ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); 
clipboard.setText("Text to copy");
clipboard.getText();

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLukapView Question on Stackoverflow
Solution 1 - AndroidChiragView Answer on Stackoverflow