0

I want to take a accessibility service instance and call there method in Activity. I tried taking

AccessibilityService as = new AccessibilityService ()

as.doSomething()

but this works for first time only.

David Wasser
  • 93,459
  • 16
  • 209
  • 274
  • First of all, you cannot instantiate `AccessibilityService`, as it is `abstract`. You need to create your own class that `extends AccessibilityService`. Secondly, you absolute positively cannot instantiate an Android `Service` using the `new` keyword. Services are Android framework components and they can only be instantiated by the Android framework directly. The framework instantiates the `Service` and sets up the `Context` and other behind-the-scenes` data structures that are necessary to ensure that the `Service` gets the appropriate lifecycle callbacks, etc. – David Wasser Feb 28 '22 at 16:36
  • What method are you trying to call? What are you trying to accomplish? – David Wasser Feb 28 '22 at 16:37
  • method to Find Scrollable node on current screen through AccessibilityService – ROHIT GANDE Mar 02 '22 at 05:58
  • You need to read about how to create an `AccessibilityService`. This isn't how you do that. – David Wasser Mar 02 '22 at 10:41

0 Answers0