I am trying to create an app , In that I want to disable all the buttons. I have managed to disable the Home, Volume and Back buttons but I'm unable to disable the Recent button.
I have tried disabling the Recent button using Accessibility but had no luck.
I'm new to Stack so guide me if I have done any mistake in asking the question.
My Code: (Which isn't working)
class MyAccessibilityService : AccessibilityService() {
override fun onInterrupt() {
}
override fun onKeyEvent(event: KeyEvent?): Boolean {
Utilsfun.ToastMsg(this,"keyevent")
return super.onKeyEvent(event)
}
override fun onAccessibilityEvent(event: AccessibilityEvent?) {
val nodeInfo = event!!.source
val className = event.getClassName()
priE("Accessbilityt", className.toString());
if (className.equals("com.android.internal.policy.impl.RecentApplicationsDialog")
|| className.equals("com.android.systemui.recent.RecentsActivity")
|| className.equals("com.android.systemui.recents.RecentsActivity")
|| className.equals("com.android.systemui.recents.SeparatedRecentsActivity")
){
performGlobalAction(GLOBAL_ACTION_BACK)
}
}
override fun onGesture(gestureId: Int): Boolean {
return super.onGesture(gestureId)
}
override fun onServiceConnected() {
super.onServiceConnected()
priE("Accessbilityt", "onServiceConnected");
}
}
I'm able to detect the action with this code but not able to disable it.