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

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.