1

I want to use canRequestFilterKeyEvents option in my accessibility service enabled app. I get a warning saying that this is supported only from API level 18 and my app minimum API is 14.

I am ok, if the features I enable using this setting is not available for users below API level 18. But i want to make sure the app would not crash in older version because this setting is enabled.

I have this setting enable in accessibility_service_config.xml file. I have given the full config below.

<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/accessibility_service_description"
android:accessibilityEventTypes="typeAllMask"
android:accessibilityFlags="flagDefault|flagReportViewIds|flagIncludeNotImportantViews|flagRequestFilterKeyEvents"
android:accessibilityFeedbackType="feedbackVisual"
android:notificationTimeout="100"
android:canRetrieveWindowContent="true"
android:canRequestFilterKeyEvents="true"
/>
Sriram
  • 8,574
  • 4
  • 21
  • 30

1 Answers1

1

It should not crash the application because android:canRequestFilterKeyEvents will not be parsed in code on pre API 18 phones. So it should be save put it there. If it somehow does crash your app you could also make 2 xml folders one named just xml and the other xml-v18

Aegis
  • 5,761
  • 2
  • 33
  • 42
  • my xml folder is named as "xml". should i rename it to "raw" or "xml-v18" would work as well? – Sriram Oct 06 '15 at 12:52
  • no you can use folder qualifiers -v18 everything inside will only be used in API 18 and up. this goes for als resource folders strings/layout/values etc. But as I said in my answer it should not crash your app. – Aegis Oct 06 '15 at 12:54
  • But since your answer is uncertain and giving me an alternate, i feel its better i go with folder qualifiers approach – Sriram Oct 06 '15 at 13:02
  • can you also look at my other question and see if you can help. http://stackoverflow.com/questions/32919396/get-share-content-through-accessibility-in-android-app – Sriram Oct 06 '15 at 13:07