How to start AccessibilityService?

后端 未结 2 1658
野趣味
野趣味 2020-12-08 22:51

I\'m trying to start my implementation of AccessibilityService by using

Intent mailAccessabilityIntent = new Intent(this, EmailAccessabilityService.class);
s         


        
2条回答
  •  一生所求
    2020-12-08 23:19

    Because accessibility services are able to explore and interact with on-screen content, a user has to explicitly enable services in Settings > Accessibility. Once a service is enabled, the system will start it automatically and bind it to the accessibility APIs.

    Make sure you declare your service in your application manifest:

    
         
             
         
         . . .
     
    

    You'll also need to provide configuration for your service, either by overriding setServiceInfo(AccessibilityServiceInfo) or adding a meta-data attribute and XML config file.

    The meta-data attribute goes in your declaration after the tag and looks like this:

    
    

    The XML config that you're referencing (in this case, accessibilityservice.xml) looks like this:

    
    

    There's more information on which tags you can use at http://developer.android.com/reference/android/R.styleable.html#AccessibilityService

提交回复
热议问题