I am using accessibility service to find a button on screen and click it, but for some reason I am getting the follow error:
java.lang.IllegalStateException: Cannot perform this action on a not sealed instance.
at android.view.accessibility.AccessibilityNodeInfo.enforceSealed(AccessibilityNodeInfo.java:3046)
at android.view.accessibility.AccessibilityNodeInfo.findAccessibilityNodeInfosByText(AccessibilityNodeInfo.java:1529)
at com.myapp.adapters.Adapter_Click$11.run(Adapter_Click.java:1874)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Method.java:-2)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
And the line that it refers to is:
List<AccessibilityNodeInfo> list = source.findAccessibilityNodeInfosByText("Accept".toLowerCase());
And then I use this to click the button:
if (view.performAction(AccessibilityNodeInfo.ACTION_CLICK))
{
Log.e(TAG, "Button clicked");
}
I didn't see any issues with this for the last year until I just recently updated to AndroidX. Is there a way to check if it is a sealed instance before trying to click it? I even tried to wrap it in a try/catch and it still crashes my app.