I have a somewhat peculiar issue; I'm trying to block the paste option in a TextInputEditText. In fact, this works perfectly on my Pixel and other devices, but for some reason, it doesn't work for Samsung and Huawei devices. This is the code I've used:
fun onRestrictCopyAndPaste(inputText: TextInputEditText, textInputLayout: TextInputLayout){
inputText.setOnLongClickListener { true }
inputText.customSelectionActionModeCallback = object : ActionMode.Callback {
override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean {
menu?.removeItem(android.R.id.paste)
return false
}
override fun onPrepareActionMode(mode: ActionMode?, menu: Menu?): Boolean {
menu?.removeItem(android.R.id.paste)
return false
}
override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean {
return false
}
override fun onDestroyActionMode(mode: ActionMode?) {}
}
}
I've tried multiple options, including filters or attempting to block double-clicking, but nothing worked for Samsung or Huawei devices. I'm unsure if they manage the menu that appears at the top differently.
It appears on the screen like this

There are still a few properties that need to be disabled to enhance security and user experience in Android:
}
Maybe the above snippet should help.