Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set text and get text from clipboard [closed]

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.

like image 487
Lukap Avatar asked Jul 11 '11 13:07

Lukap


People also ask

How do I put text on my Android clipboard?

Android Clipboard Methods setPrimaryClip(ClipData clip) – This method sets the primary clip on the clipboard. getText() – This method directly gets the copied text from the clipboard. setText(CharSequence text) – This method directly copies text into the clipboard.

How do I find clipboard data on Android?

Open the messaging app on your Android, and press the + symbol to the left of the text field. Select the keyboard icon. When the keyboard appears, select the > symbol at the top. Here, you can tap the clipboard icon to open the Android clipboard.


1 Answers

ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);  clipboard.setText("Text to copy"); clipboard.getText(); 
like image 120
Chirag Avatar answered Sep 19 '22 12:09

Chirag