0

I am sticking at the following problem: I want to react on AccessibilityEvents in the Android Settings. For example I want to do a specific action when the user taps on Location. The problem occurs when I switch the language of the device. Then it says for event.getText() a different text and so I am not able to react on "Location" anymore. Is there any way to get an unique ID for the Subsettings Location etc?

Best Alex

Alex
  • 459
  • 3
  • 14

2 Answers2

1

In your onServiceConnected function, try this:

AccessibilityServiceInfo tempInfo = getServiceInfo();
tempInfo.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
tempInfo.flags |= AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS;
setServiceInfo(tempInfo);

We add include no important views in case the crucial id is on a layout of the view that your looking for. The report view ids flag will report the id of views that have a named resource. Should the view (or it's hierarchical layout) not have a named resource, unfortunately you are stuck. You can attempt to grab the root view, and calculate where the view is, based on the entirety of the hierarchy. For example, if you knew it was the fifth view, next to such and such view ID that is another approach.

MobA11y
  • 18,425
  • 3
  • 49
  • 76
0

I think one way is to translate Location word into other languages and create one list of string and just match the selected node's text and perform desired action :)
because i think there are no unique id's for every accessibility node.

Kunal
  • 55
  • 1
  • 9