0

I have set CustomSelectionActionModeCallback to an edittext as below

    new ActionMode.Callback() {
    @Override
    public boolean onCreateActionMode(ActionMode mode, Menu menu) {
        return false;
    }

    @Override
    public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
        return false;
    }

    @Override
    public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
        return false;
    }

    @Override
    public void onDestroyActionMode(ActionMode mode) {

    }
};

to disable paste option on edittext,but still user can paste by tapping on the cursor .I tried to create custom edittext class and override canPaste(),but still no luck.Can anybody suggest a correct solution. Thanks.

Apparently the problem is observed in lollipop+ devices only

Raji A C
  • 2,261
  • 4
  • 26
  • 31

1 Answers1

0

Another method one would suggest is to call setLongClickable(false) on the EditText, although that still doesn't prevent pasting from tapping on the cursor.

The proper (or only :) way to do this is to create a custom EditText and override isSuggestionsEnabled and canPaste methods.

Check this answer for an example.

Community
  • 1
  • 1
earthw0rmjim
  • 19,027
  • 9
  • 49
  • 63