Android how to detect Copy event of Edittext in android

android, copy, events

Solution

I got solutions: I create one service : on that in oncreate :

         ClipboardManager clipBoard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
         clipBoard.addPrimaryClipChangedListener(new ClipboardListener());

and add in service :

        class ClipboardListener implements
        ClipboardManager.OnPrimaryClipChangedListener {
        public void onPrimaryClipChanged() {
        ClipboardManager clipBoard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
        CharSequence pasteData = "";
        ClipData.Item item = clipBoard.getPrimaryClip().getItemAt(0);
        pasteData = item.getText();
        Toast.makeText(getApplicationContext(), "copied val=" + pasteData,
                Toast.LENGTH_SHORT).show();

    }
}

Problem

I have one android apps in that i want : whenever user press copy from the edittext,any event occure, it any of edittext like from messenger edittext,mail edittext any one,when user press copy text, i want to occure any event,so any body give me example for this ?i have no idea about it,so please help me, thanks in advance.

Original source

Related problems