0

Has anyone implemented accessibility service? I have a requirement where in I need to know when home key is pressed from a service. I am wondering if AccessbilityService is the solution .unfortunately there are not many tutorials on the same ? Any code examples available?

rds
  • 26,253
  • 19
  • 107
  • 134
Preethi
  • 2,112
  • 7
  • 38
  • 54

2 Answers2

0

You cannot determine when home button is pressed...

MimmoG
  • 631
  • 3
  • 14
  • 25
0

Accessbility service can be used , if you know the home package( which can be inferred from logcat) then event is generated when user goes to home screen

NOTE : But the user has to explicitly set the Settings -> Accessibilty ->Check the application name .

There is another way to know when the home screen is invoked , from service . Start reading the logs to know when home intent was sent though i am not sure whether it is the right way .

Preethi
  • 2,112
  • 7
  • 38
  • 54