How to copy text from anywhere outside the app and paste it in the EditText?

I have done the following:
//for copy
var clipboard = (ClipboardManager)GetSystemService(ClipboardService);
var clip = ClipData.NewPlainText("1234", "Text copy");

        clipboard.PrimaryClip = clip;

        // And paste it
        var clipboard1 = (ClipboardManager)GetSystemService(ClipboardService);

        var pasteData = "";

        if (!(clipboard1.HasPrimaryClip))
            // If it does contain data, decide if you can handle the data.

        else if (!(clipboard1.PrimaryClipDescription.HasMimeType(ClipDescription.MimetypeTextPlain)))

            // since the clipboard has data but it is not plain text

            //since the clipboard contains plain text.
            var item = clipboard1.PrimaryClip.GetItemAt(0);

            // Gets the clipboard as text.
            pasteData = item.Text;

This perfectly copies anything that I type on one EditText and pastes it on another EditText in the emulator , However, when I try to copy some text from MS Word or browser , it is not pasted in the EditText.
Please help.

Best Answer


  • ArvindrajaArvindraja INMember ✭✭✭
    edited October 2016

    by default copy paste working in emulators(u asked about emulators) no need to develop
    if you want selection enable for text use selectable="true" and longclicking="true"

    see the screenshot where i'm pasting text copied from emulator only.


  • I am already able to do that( pasting text copied from emulator only) , However, I want to paste text from outside the emulator.

Sign In or Register to comment.