Is it possible to send past command so that it pastes text into currently focused edit text. Scenario:
I know how to copy text with ClipboardManager
, but I don't know how to paste it.
you can copy and paste text using following code :
for copy :
ClipboardManager clipboard = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("your_text_to_be_copied");
clipboard.setPrimaryClip(clip);
And paste it :
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
String pasteData = "";
// If it does contain data, decide if you can handle the data.
if (!(clipboard.hasPrimaryClip())) {
} else if (!(clipboard.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN))) {
// since the clipboard has data but it is not plain text
} else {
//since the clipboard contains plain text.
ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);
// Gets the clipboard as text.
pasteData = item.getText().toString();
}
for more details check here