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
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()
}