Android APIThe Chinese Document AccessibilityService is the content to be introduced in this article, mainly to understand and learnAndroid APIThe content of the help document.Android APIFor more information, see this article.
I. Android API Structure
- java.lang.Object
- android.content.Context
- android.content.ContextWrapper
- android.app.Service
- android.accessibilityservice.AccessibilityService
- public abstract class AccessibilityService extends Service
Ii. Android API Overview
In the Android API, when an AccessibilityEvent event is started, the AccessibilityService receives the callback function and runs it in the background. These events refer to status changes between user interfaces, such as focus changes, button is clicked. Some auxiliary services inherit from this class and implement its abstract methods. A service like this is declared in AndroidManifest. xml, but it must be specified for operation.
Android. accessibilityservice. AccessibilityService intent. The following is an example:
- <service android:name=".MyAccessibilityService">
- <intent-filter>
- <action android:name="android.accessibilityservice.AccessibilityService" />
- </intent-filter>
- </service>
In Android APIs, the life cycle of the auxiliary service can only be managed by the system. To start or stop the service, a clear user must call onServiceConnected () in the system by enabling or disabling the device () after the method is bound to the service, this method can be used by the client that wants to execute the load. A secondary service sets the AccessibilityServiceInfo by calling the setServiceInfo (AccessibilityServiceInfo) method. You can change the configuration of this service at any time, but it is best to use it in the overload method onServiceConnected.
An auxiliary service can register events in a specific package to provide special feedback types and send a clear timeout reminder when the last associated event is released.
3. Android API announcement Policy
In the Android API, only one secondary service is notified for each feedback type, and the service registry is notified in order. Therefore, if two services are registered for the same feedback type in the same package, the first one will be notified. However, it is possible that, you can register a service as the default for a given feedback type. In this way, if no other service is used to replace this event, the service will be called out. In other words, the default service will not compete with other services and will be notified regardless of the order of registration.
Iv. Android API public methods:
- abstract void onAccessibilityEvent(AccessibilityEvent event)
Callback AccessibilityEvents.
Parameters
Event
- public final IBinder onBind (Intent intent)
The implementation returns the implementation of an internal secondary interface, and the subclass cannot be overwritten.
Parameters
Intent indicates the Intent bound to the service. Note that any other external intent contained in the Intent cannot be used here.
Return Value
Returns the IBinder that a client can access on the service.
- public abstract void onInterrupt ()
Call when the secondary feedback content is interrupted.
5. Android API protection methods:
- protected void onServiceConnected ()
This method is part of the AccessibilityService declaration cycle and is called only after the system is successfully bound to the service. This method is more convenient if it is used to set AccessibilityServiceInfo.
Summary:Android APIThe content of AccessibilityService in the Chinese document is described.Android APIDocument learning is helpful to you.