I've got an AccessibilityEvent
which can stop app automatically. But when starting app info intent, it goes to infinite loop of turn on/off alert dialog.
How can I prevent it ? Here's the code:
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
if (AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED == event
.getEventType()) {
AccessibilityNodeInfo nodeInfo = event.getSource();
if (nodeInfo == null) {
return;
}
List<AccessibilityNodeInfo> list = nodeInfo
.findAccessibilityNodeInfosByViewId("com.android.settings:id/force_stop_button");
for (AccessibilityNodeInfo node : list) {
Log.i(TAG, "check1 = " + check);
node.performAction(AccessibilityNodeInfo.ACTION_CLICK);
check = true;
}
list = nodeInfo
.findAccessibilityNodeInfosByText("CANCEL");
for (AccessibilityNodeInfo node : list) {
node.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
}
}
And by the way, any idea to get the force_stop_button
clicked immediately after the app info intent started ?
EDIT: I think the problem is in AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
. If I bypass that check, it works, but really hard to control.