Yogendra
Yogendra

Reputation: 21

Accessibility Service in android tv app disabled automatically (showing enabled in right side on detail view &in left side at app name it showing off)

I have created android tv app by using custom accessibility service. I am using it to listen "HOME" button key event to launch my app (when user presses "HOME" button on d-pad). Everything works fine but sometimes I observed, the accessibility service get disabled automatically.

When I checked to Settings > Accessibility > My_APP, I found the below case.

  1. My_APP > showing accessibility as "OFF"
  2. When I clicked and moved to "enable" the service, it was showing "Enabled" flag as ON(means, it was enabled as shown in images)
  1. showing "Off" in app name
  2. showing "Enabled" when goto enable

What is the reason behind this? What I am doing wrong here or How I need to handle this, where accessibility should not disabled automatically until user disables it?

Below is my service_config.xml

<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:accessibilityEventTypes="typeViewClicked"
    android:accessibilityFeedbackType="feedbackGeneric|feedbackVisual"
    android:canRetrieveWindowContent="true"
    android:accessibilityFlags="flagReportViewIds|flagRequestFilterKeyEvents"
    android:description="@string/app_name"
    android:canPerformGestures="true"
    android:canRequestFilterKeyEvents ="true"
    android:notificationTimeout="150"/>

My app has sdk support as below: minSdk = 26, targetSdk = 34 and AGP version = 8.3.2

I have tried this on google chrome cast with android 12.

Upvotes: 2

Views: 801

Answers (2)

Herlandro Hermogenes
Herlandro Hermogenes

Reputation: 1111

Your accessibility service is being automatically disabled because Android restricts apps from intercepting protected key events like the “HOME” button for security reasons. When your app tries to listen for the “HOME” button press, the system may detect this and disable your service to prevent misuse. To resolve this, avoid intercepting the “HOME” button and redesign your app to function without relying on capturing this key event.

Upvotes: 0

Nurlan Alisgandarli
Nurlan Alisgandarli

Reputation: 1

It happens on my tv tv security app make this, disable it with adb or give permission in security app too it work on my tcl google tv

Upvotes: 0

Related Questions