1

I want to remove clipboard option from keyboard when click on my edittext so that can't paste data from third party apps. I have gone through multiple links as below:

For clear all clip: Clear ALL clipboard entries

For disable copy/paste: Android: How to TOTALLY disable copy and paste function in Edittext

https://www.folkstalk.com/2022/09/how-to-disable-paste-button-in-edittext-android-with-code-examples.html

I have used below code for preventing paste:

override fun onTextContextMenuItem(id: Int): Boolean {
    val consumed = super.onTextContextMenuItem(id)
    when (id) {
        R.id.cut -> onTextCut()
        R.id.paste -> onTextPaste()
        R.id.copy -> onTextCopy()
    }
    return consumed
}

fun onTextCut() {}
fun onTextCopy() {}

/**
 * adding listener for Paste for example
 */
fun onTextPaste() {
    text?.clear()
}
D.J
  • 1,439
  • 1
  • 12
  • 23
  • 1
    Whether the developers of a keyboard offer pasting from the clipboard is up to the developers of the keyboard. Not all offer that, and apps have no means of controlling that. – CommonsWare Nov 18 '22 at 13:08

0 Answers0