Is it possible to send past command so that it pastes text into currently focused edit text. Scenario:
- Background service listening for notification (done)
- When notification is received text needs to be copied to clipboard (done)
- Paste text to any currently focused field, if not possible just discard paste command.
I know how to copy text with ClipboardManager
, but I don't know how to paste it.
If you just want to "copy and paste" some code into your app, you can use the following.
Copy
Paste
Get the text to paste
or
Inserting it at the cursor position
If there is a selection then the selection will be replaced with the paste text.
Notes
android.content.ClipboardManager
andandroid.content.ClipData
.you can copy and paste text using following code :
for copy :
And paste it :
for more details check here
a short summary of above after honeycomb >= API 13:
I do it this way. Clipboard manager for all api levels.