AkhileshSoni
AkhileshSoni

Reputation: 380

Why Accessibility service does not respond to onKeyEvent on all nexus devices?

I am creating an app with Accessibility Service and I want to do some task when the back button or home button is pressed.For that purpose I added the following attribute in xml file:-

  1. I added the flagRequestFilterKeyEvents flag.
  2. Also set android:canRequestFilterKeyEvents="true".

The service is responding in other devices except the nexus device. I am not able to understand that, why its not responding in nexus phones.

please share your knowledge with me.

Upvotes: 1

Views: 839

Answers (1)

MobA11y
MobA11y

Reputation: 18860

Back button and Home Button are not keys. The actions may be implemented this way on some platforms (for example the back button could send the "escape" KeyEvent). But, this is NOT required.

In this case "KeyEvent" refers to a hardware keyboard (ex: a bluetooth keyboard). Note: software keyboards can be implemented to send these events as well, but they are not required to, and it should not be relied on.

On Nexus Devices, the back and home buttons are actually on screen software buttons. Thus, like the difference between a hardware and software keyboard, those events are not passed through the system in the same way as devices where there are physical back buttons to press.

Upvotes: 1

Related Questions