public abstract class AccessibilityService extends Service
AccessibilityEvent
s are fired. Such events denote some state transition
in the user interface, for example, the focus has changed, a button has been clicked,
etc. Such a service can optionally request the capability for querying the content
of the active window. Development of an accessibility service requires extending this
class and implementing its abstract methods.
For more information about creating AccessibilityServices, read the Accessibility developer guide.
The lifecycle of an accessibility service is managed exclusively by the system and
follows the established service life cycle. Starting an accessibility service is triggered
exclusively by the user explicitly turning the service on in device settings. After the system
binds to a service, it calls onServiceConnected()
. This method can
be overriden by clients that want to perform post binding setup.
An accessibility service stops either when the user turns it off in device settings or when
it calls disableSelf()
.
An accessibility is declared as any other service in an AndroidManifest.xml, but it must do two things:
Intent
.
android.Manifest.permission#BIND_ACCESSIBILITY_SERVICE
permission to
ensure that only the system can bind to it.
<service android:name=".MyAccessibilityService" android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"> <intent-filter> <action android:name="android.accessibilityservice.AccessibilityService" /> </intent-filter> . . . </service>
An accessibility service can be configured to receive specific types of accessibility events, listen only to specific packages, get events from each type only once in a given time frame, retrieve window content, specify a settings activity, etc.
There are two approaches for configuring an accessibility service:
meta-data
entry in the manifest when declaring
the service. A service declaration with a meta-data tag is presented below:
<service android:name=".MyAccessibilityService"> <intent-filter> <action android:name="android.accessibilityservice.AccessibilityService" /> </intent-filter> <meta-data android:name="android.accessibilityservice" android:resource="@xml/accessibilityservice" /> </service>
Note: This approach enables setting all properties.
For more details refer to SERVICE_META_DATA
and
<
.
accessibility-service
>
setServiceInfo(AccessibilityServiceInfo)
. Note
that this method can be called any time to dynamically change the service configuration.
Note: This approach enables setting only dynamically configurable properties:
AccessibilityServiceInfo.eventTypes
,
AccessibilityServiceInfo.feedbackType
,
AccessibilityServiceInfo.flags
,
AccessibilityServiceInfo.notificationTimeout
,
AccessibilityServiceInfo.packageNames
For more details refer to AccessibilityServiceInfo
.
A service can specify in its declaration that it can retrieve window
content which is represented as a tree of AccessibilityWindowInfo
and
AccessibilityNodeInfo
objects. Note that
declaring this capability requires that the service declares its configuration via
an XML resource referenced by SERVICE_META_DATA
.
Window content may be retrieved with
AccessibilityEvent.getSource()
,
findFocus(int)
,
getWindows()
, or
getRootInActiveWindow()
.
Note An accessibility service may have requested to be notified for a subset of the event types, and thus be unaware when the node hierarchy has changed. It is also possible for a node to contain outdated information because the window content may change at any time.
All accessibility services are notified of all events they have requested, regardless of their feedback type.
Note: The event notification timeout is useful to avoid propagating events to the client too frequently since this is accomplished via an expensive interprocess call. One can think of the timeout as a criteria to determine when event generation has settled down.
AccessibilityEvent.TYPE_VIEW_CLICKED
AccessibilityEvent.TYPE_VIEW_LONG_CLICKED
AccessibilityEvent.TYPE_VIEW_FOCUSED
AccessibilityEvent.TYPE_VIEW_SELECTED
AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED
AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED
AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START
AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END
AccessibilityEvent.TYPE_VIEW_HOVER_ENTER
AccessibilityEvent.TYPE_VIEW_HOVER_EXIT
AccessibilityEvent.TYPE_VIEW_SCROLLED
AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED
AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
AccessibilityEvent.TYPE_ANNOUNCEMENT
AccessibilityEvent.TYPE_GESTURE_DETECTION_START
AccessibilityEvent.TYPE_GESTURE_DETECTION_END
AccessibilityEvent.TYPE_TOUCH_INTERACTION_START
AccessibilityEvent.TYPE_TOUCH_INTERACTION_END
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED
AccessibilityEvent.TYPE_WINDOWS_CHANGED
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED
Modifier and Type | Class and Description |
---|---|
static interface |
AccessibilityService.Callbacks |
static class |
AccessibilityService.GestureResultCallback
Class used to report status of dispatched gestures
|
static class |
AccessibilityService.IAccessibilityServiceClientWrapper
Implements the internal
IAccessibilityServiceClient interface to convert
incoming calls to it back to calls on an AccessibilityService . |
static class |
AccessibilityService.MagnificationController
Used to control and query the state of display magnification.
|
static class |
AccessibilityService.SoftKeyboardController
Used to control and query the soft keyboard show mode.
|
static interface |
AccessibilityService.SoftKeyboardShowMode
Annotations for Soft Keyboard show modes so tools can catch invalid show modes.
|
Service.StartArgFlags, Service.StartResult, Service.StopForegroundFlags
Context.BindServiceFlags, Context.CreatePackageOptions, Context.ServiceName
Modifier and Type | Field and Description |
---|---|
static int |
GESTURE_SWIPE_DOWN
The user has performed a swipe down gesture on the touch screen.
|
static int |
GESTURE_SWIPE_DOWN_AND_LEFT
The user has performed an down and left gesture on the touch screen.
|
static int |
GESTURE_SWIPE_DOWN_AND_RIGHT
The user has performed an down and right gesture on the touch screen.
|
static int |
GESTURE_SWIPE_DOWN_AND_UP
The user has performed a swipe down and up gesture on the touch screen.
|
static int |
GESTURE_SWIPE_LEFT
The user has performed a swipe left gesture on the touch screen.
|
static int |
GESTURE_SWIPE_LEFT_AND_DOWN
The user has performed a left and down gesture on the touch screen.
|
static int |
GESTURE_SWIPE_LEFT_AND_RIGHT
The user has performed a swipe left and right gesture on the touch screen.
|
static int |
GESTURE_SWIPE_LEFT_AND_UP
The user has performed a left and up gesture on the touch screen.
|
static int |
GESTURE_SWIPE_RIGHT
The user has performed a swipe right gesture on the touch screen.
|
static int |
GESTURE_SWIPE_RIGHT_AND_DOWN
The user has performed a right and down gesture on the touch screen.
|
static int |
GESTURE_SWIPE_RIGHT_AND_LEFT
The user has performed a swipe right and left gesture on the touch screen.
|
static int |
GESTURE_SWIPE_RIGHT_AND_UP
The user has performed a right and up gesture on the touch screen.
|
static int |
GESTURE_SWIPE_UP
The user has performed a swipe up gesture on the touch screen.
|
static int |
GESTURE_SWIPE_UP_AND_DOWN
The user has performed a swipe up and down gesture on the touch screen.
|
static int |
GESTURE_SWIPE_UP_AND_LEFT
The user has performed an up and left gesture on the touch screen.
|
static int |
GESTURE_SWIPE_UP_AND_RIGHT
The user has performed an up and right gesture on the touch screen.
|
static int |
GLOBAL_ACTION_BACK
Action to go back.
|
static int |
GLOBAL_ACTION_HOME
Action to go home.
|
static int |
GLOBAL_ACTION_NOTIFICATIONS
Action to open the notifications.
|
static int |
GLOBAL_ACTION_POWER_DIALOG
Action to open the power long-press dialog.
|
static int |
GLOBAL_ACTION_QUICK_SETTINGS
Action to open the quick settings.
|
static int |
GLOBAL_ACTION_RECENTS
Action to toggle showing the overview of recent apps
|
static int |
GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN
Action to toggle docking the current app's window
|
static String |
SERVICE_INTERFACE
The
Intent that must be declared as handled by the service. |
static String |
SERVICE_META_DATA
Name under which an AccessibilityService component publishes information
about itself.
|
static int |
SHOW_MODE_AUTO |
static int |
SHOW_MODE_HIDDEN |
START_CONTINUATION_MASK, START_FLAG_REDELIVERY, START_FLAG_RETRY, START_NOT_STICKY, START_REDELIVER_INTENT, START_STICKY, START_STICKY_COMPATIBILITY, START_TASK_REMOVED_COMPLETE, STOP_FOREGROUND_DETACH, STOP_FOREGROUND_REMOVE
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BACKUP_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_ALLOW_WHITELIST_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_EXTERNAL_SERVICE, BIND_FOREGROUND_SERVICE, BIND_FOREGROUND_SERVICE_WHILE_AWAKE, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_NOT_VISIBLE, BIND_SHOWING_UI, BIND_TREAT_LIKE_ACTIVITY, BIND_VISIBLE, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_CREDENTIAL_PROTECTED_STORAGE, CONTEXT_DEVICE_PROTECTED_STORAGE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_REGISTER_PACKAGE, CONTEXT_RESTRICTED, CONTEXTHUB_SERVICE, COUNTRY_DETECTOR, DEVICE_IDLE_CONTROLLER, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, ETHERNET_SERVICE, FINGERPRINT_SERVICE, GATEKEEPER_SERVICE, HARDWARE_PROPERTIES_SERVICE, HDMI_CONTROL_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_NO_LOCALIZED_COLLATORS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_POLICY_SERVICE, NETWORK_SCORE_SERVICE, NETWORK_STATS_SERVICE, NETWORKMANAGEMENT_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, PERSISTENT_DATA_BLOCK_SERVICE, POWER_SERVICE, PRINT_SERVICE, RADIO_SERVICE, RECOVERY_SERVICE, RESTRICTIONS_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, SERIAL_SERVICE, SHORTCUT_SERVICE, SIP_SERVICE, SOUND_TRIGGER_SERVICE, STATUS_BAR_SERVICE, STORAGE_SERVICE, SYSTEM_HEALTH_SERVICE, TELECOM_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TRUST_SERVICE, TV_INPUT_SERVICE, UI_MODE_SERVICE, UPDATE_LOCK_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, VOICE_INTERACTION_MANAGER_SERVICE, WALLPAPER_SERVICE, WIFI_NAN_SERVICE, WIFI_P2P_SERVICE, WIFI_RTT_SERVICE, WIFI_SCANNING_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
Constructor and Description |
---|
AccessibilityService() |
Modifier and Type | Method and Description |
---|---|
void |
disableSelf()
Disables the service.
|
boolean |
dispatchGesture(GestureDescription gesture,
AccessibilityService.GestureResultCallback callback,
Handler handler)
Dispatch a gesture to the touch screen.
|
AccessibilityNodeInfo |
findFocus(int focus)
Find the view that has the specified focus type.
|
AccessibilityService.MagnificationController |
getMagnificationController()
Returns the magnification controller, which may be used to query and
modify the state of display magnification.
|
AccessibilityNodeInfo |
getRootInActiveWindow()
Gets the root node in the currently active window if this service
can retrieve window content.
|
AccessibilityServiceInfo |
getServiceInfo()
Gets the an
AccessibilityServiceInfo describing this
AccessibilityService . |
AccessibilityService.SoftKeyboardController |
getSoftKeyboardController()
Returns the soft keyboard controller, which may be used to query and modify the soft keyboard
show mode.
|
Object |
getSystemService(String name)
Return the handle to a system-level service by name.
|
List<AccessibilityWindowInfo> |
getWindows()
Gets the windows on the screen.
|
abstract void |
onAccessibilityEvent(AccessibilityEvent event)
Callback for
AccessibilityEvent s. |
IBinder |
onBind(Intent intent)
Implement to return the implementation of the internal accessibility
service interface.
|
protected boolean |
onGesture(int gestureId)
Called by the system when the user performs a specific gesture on the
touch screen.
|
abstract void |
onInterrupt()
Callback for interrupting the accessibility feedback.
|
protected boolean |
onKeyEvent(KeyEvent event)
Callback that allows an accessibility service to observe the key events
before they are passed to the rest of the system.
|
protected void |
onServiceConnected()
This method is a part of the
AccessibilityService lifecycle and is
called after the system has successfully bound to the service. |
boolean |
performGlobalAction(int action)
Performs a global action.
|
void |
setServiceInfo(AccessibilityServiceInfo info)
Sets the
AccessibilityServiceInfo that describes this service. |
attach, dump, getApplication, onConfigurationChanged, onCreate, onDestroy, onLowMemory, onRebind, onStart, onStartCommand, onTaskRemoved, onTrimMemory, onUnbind, setForeground, startForeground, stopForeground, stopForeground, stopSelf, stopSelf, stopSelfResult
attachBaseContext, bindService, bindServiceAsUser, canStartActivityForResult, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, checkUriPermission, clearWallpaper, createApplicationContext, createConfigurationContext, createCredentialProtectedStorageContext, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, createPackageContextAsUser, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getBasePackageName, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDataDir, getDir, getDisplay, getDisplayAdjustments, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getOpPackageName, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSharedPreferences, getSharedPreferencesPath, getSystemServiceName, getTheme, getThemeResId, getUserId, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isCredentialProtectedStorage, isDeviceProtectedStorage, isRestricted, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, registerReceiverAsUser, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendBroadcastAsUser, sendBroadcastMultiplePermissions, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendOrderedBroadcastAsUser, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivitiesAsUser, startActivity, startActivity, startActivityAsUser, startActivityAsUser, startActivityForResult, startInstrumentation, startIntentSender, startIntentSender, startService, startServiceAsUser, stopService, stopServiceAsUser, unbindService, unregisterReceiver
bindServiceAsUser, createCredentialEncryptedStorageContext, createDeviceEncryptedStorageContext, getColor, getColorStateList, getDrawable, getSharedPrefsFile, getString, getString, getSystemService, getText, isCredentialEncryptedStorage, isDeviceEncryptedStorage, migrateDatabaseFrom, migrateSharedPreferencesFrom, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
public static final int GESTURE_SWIPE_UP
public static final int GESTURE_SWIPE_DOWN
public static final int GESTURE_SWIPE_LEFT
public static final int GESTURE_SWIPE_RIGHT
public static final int GESTURE_SWIPE_LEFT_AND_RIGHT
public static final int GESTURE_SWIPE_RIGHT_AND_LEFT
public static final int GESTURE_SWIPE_UP_AND_DOWN
public static final int GESTURE_SWIPE_DOWN_AND_UP
public static final int GESTURE_SWIPE_LEFT_AND_UP
public static final int GESTURE_SWIPE_LEFT_AND_DOWN
public static final int GESTURE_SWIPE_RIGHT_AND_UP
public static final int GESTURE_SWIPE_RIGHT_AND_DOWN
public static final int GESTURE_SWIPE_UP_AND_LEFT
public static final int GESTURE_SWIPE_UP_AND_RIGHT
public static final int GESTURE_SWIPE_DOWN_AND_LEFT
public static final int GESTURE_SWIPE_DOWN_AND_RIGHT
public static final String SERVICE_INTERFACE
Intent
that must be declared as handled by the service.public static final String SERVICE_META_DATA
<accessibility-service
>
tag. This is a a sample XML file configuring an accessibility service:
<accessibility-service android:accessibilityEventTypes="typeViewClicked|typeViewFocused" android:packageNames="foo.bar, foo.baz" android:accessibilityFeedbackType="feedbackSpoken" android:notificationTimeout="100" android:accessibilityFlags="flagDefault" android:settingsActivity="foo.bar.TestBackActivity" android:canRetrieveWindowContent="true" android:canRequestTouchExplorationMode="true" . . . />
public static final int GLOBAL_ACTION_BACK
public static final int GLOBAL_ACTION_HOME
public static final int GLOBAL_ACTION_RECENTS
public static final int GLOBAL_ACTION_NOTIFICATIONS
public static final int GLOBAL_ACTION_QUICK_SETTINGS
public static final int GLOBAL_ACTION_POWER_DIALOG
public static final int GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN
public static final int SHOW_MODE_AUTO
public static final int SHOW_MODE_HIDDEN
public abstract void onAccessibilityEvent(AccessibilityEvent event)
AccessibilityEvent
s.event
- The new event. This event is owned by the caller and cannot be used after
this method returns. Services wishing to use the event after this method returns should
make a copy.public abstract void onInterrupt()
protected void onServiceConnected()
AccessibilityService
lifecycle and is
called after the system has successfully bound to the service. If is
convenient to use this method for setting the AccessibilityServiceInfo
.protected boolean onGesture(int gestureId)
AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE
flag.gestureId
- The unique id of the performed gesture.GESTURE_SWIPE_UP
,
GESTURE_SWIPE_UP_AND_LEFT
,
GESTURE_SWIPE_UP_AND_DOWN
,
GESTURE_SWIPE_UP_AND_RIGHT
,
GESTURE_SWIPE_DOWN
,
GESTURE_SWIPE_DOWN_AND_LEFT
,
GESTURE_SWIPE_DOWN_AND_UP
,
GESTURE_SWIPE_DOWN_AND_RIGHT
,
GESTURE_SWIPE_LEFT
,
GESTURE_SWIPE_LEFT_AND_UP
,
GESTURE_SWIPE_LEFT_AND_RIGHT
,
GESTURE_SWIPE_LEFT_AND_DOWN
,
GESTURE_SWIPE_RIGHT
,
GESTURE_SWIPE_RIGHT_AND_UP
,
GESTURE_SWIPE_RIGHT_AND_LEFT
,
GESTURE_SWIPE_RIGHT_AND_DOWN
protected boolean onKeyEvent(KeyEvent event)
Note: It is important that key events are handled in such a way that the event stream that would be passed to the rest of the system is well-formed. For example, handling the down event but not the up event and vice versa would generate an inconsistent event stream.
Note: The key events delivered in this method are copies and modifying them will have no effect on the events that will be passed to the system. This method is intended to perform purely filtering functionality.
event
- The event to be processed. This event is owned by the caller and cannot be used
after this method returns. Services wishing to use the event after this method returns should
make a copy.public List<AccessibilityWindowInfo> getWindows()
Note: In order to access the windows your service has
to declare the capability to retrieve window content by setting the
android.R.styleable#AccessibilityService_canRetrieveWindowContent
property in its meta-data. For details refer to SERVICE_META_DATA
.
Also the service has to opt-in to retrieve the interactive windows by
setting the AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS
flag.
public AccessibilityNodeInfo getRootInActiveWindow()
The currently active window is defined as the window that most recently fired one
of the following events:
AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
,
AccessibilityEvent.TYPE_VIEW_HOVER_ENTER
,
AccessibilityEvent.TYPE_VIEW_HOVER_EXIT
.
In other words, the last window shown that also has input focus.
Note: In order to access the root node your service has
to declare the capability to retrieve window content by setting the
android.R.styleable#AccessibilityService_canRetrieveWindowContent
property in its meta-data. For details refer to SERVICE_META_DATA
.
public final void disableSelf()
public final AccessibilityService.MagnificationController getMagnificationController()
Note: In order to control magnification, your service
must declare the capability by setting the
android.R.styleable#AccessibilityService_canControlMagnification
property in its meta-data. For more information, see
SERVICE_META_DATA
.
public final boolean dispatchGesture(GestureDescription gesture, AccessibilityService.GestureResultCallback callback, Handler handler)
The gesture will be dispatched as if it were performed directly on the screen by a user, so the events may be affected by features such as magnification and explore by touch.
Note: In order to dispatch gestures, your service
must declare the capability by setting the
android.R.styleable#AccessibilityService_canPerformGestures
property in its meta-data. For more information, see
SERVICE_META_DATA
.
gesture
- The gesture to dispatchcallback
- The object to call back when the status of the gesture is known. If
null
, no status is reported.handler
- The handler on which to call back the callback
object. If
null
, the object is called back on the service's main thread.true
if the gesture is dispatched, false
if not.public final AccessibilityService.SoftKeyboardController getSoftKeyboardController()
public final boolean performGlobalAction(int action)
action
- The action to perform.GLOBAL_ACTION_BACK
,
GLOBAL_ACTION_HOME
,
GLOBAL_ACTION_NOTIFICATIONS
,
GLOBAL_ACTION_RECENTS
public AccessibilityNodeInfo findFocus(int focus)
Note: In order to access the windows your service has
to declare the capability to retrieve window content by setting the
android.R.styleable#AccessibilityService_canRetrieveWindowContent
property in its meta-data. For details refer to SERVICE_META_DATA
.
Also the service has to opt-in to retrieve the interactive windows by
setting the AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS
flag. Otherwise, the search will be performed only in the active window.
focus
- The focus to find. One of AccessibilityNodeInfo.FOCUS_INPUT
or
AccessibilityNodeInfo.FOCUS_ACCESSIBILITY
.AccessibilityNodeInfo.FOCUS_INPUT
,
AccessibilityNodeInfo.FOCUS_ACCESSIBILITY
public final AccessibilityServiceInfo getServiceInfo()
AccessibilityServiceInfo
describing this
AccessibilityService
. This method is useful if one wants
to change some of the dynamically configurable properties at
runtime.AccessibilityServiceInfo
public final void setServiceInfo(AccessibilityServiceInfo info)
AccessibilityServiceInfo
that describes this service.
Note: You can call this method any time but the info will be picked up after the system has bound to this service and when this method is called thereafter.
info
- The info.public Object getSystemService(String name)
Context
Context.WINDOW_SERVICE
("window")
WindowManager
.
Context.LAYOUT_INFLATER_SERVICE
("layout_inflater")
LayoutInflater
for inflating layout resources
in this context.
Context.ACTIVITY_SERVICE
("activity")
ActivityManager
for interacting with the
global activity state of the system.
Context.POWER_SERVICE
("power")
PowerManager
for controlling power
management.
Context.ALARM_SERVICE
("alarm")
AlarmManager
for receiving intents at the
time of your choosing.
Context.NOTIFICATION_SERVICE
("notification")
NotificationManager
for informing the user
of background events.
Context.KEYGUARD_SERVICE
("keyguard")
KeyguardManager
for controlling keyguard.
Context.LOCATION_SERVICE
("location")
LocationManager
for controlling location
(e.g., GPS) updates.
Context.SEARCH_SERVICE
("search")
SearchManager
for handling search.
Context.VIBRATOR_SERVICE
("vibrator")
Vibrator
for interacting with the vibrator
hardware.
Context.CONNECTIVITY_SERVICE
("connection")
ConnectivityManager
for
handling management of network connections.
Context.WIFI_SERVICE
("wifi")
WifiManager
for management of Wi-Fi
connectivity. On releases before NYC, it should only be obtained from an application
context, and not from any other derived context to avoid memory leaks within the calling
process.
Context.WIFI_P2P_SERVICE
("wifip2p")
WifiP2pManager
for management of
Wi-Fi Direct connectivity.
Context.INPUT_METHOD_SERVICE
("input_method")
InputMethodManager
for management of input methods.
Context.UI_MODE_SERVICE
("uimode")
UiModeManager
for controlling UI modes.
Context.DOWNLOAD_SERVICE
("download")
DownloadManager
for requesting HTTP downloads
Context.BATTERY_SERVICE
("batterymanager")
BatteryManager
for managing battery state
Context.JOB_SCHEDULER_SERVICE
("taskmanager")
JobScheduler
for managing scheduled tasks
Context.NETWORK_STATS_SERVICE
("netstats")
NetworkStatsManager
for querying network
usage statistics.
Context.HARDWARE_PROPERTIES_SERVICE
("hardware_properties")
HardwarePropertiesManager
for accessing hardware properties.
Note: System services obtained via this API may be closely associated with the Context in which they are obtained from. In general, do not share the service objects between various different contexts (Activities, Applications, Services, Providers, etc.)
getSystemService
in class ContextWrapper
name
- The name of the desired service.Context.WINDOW_SERVICE
,
WindowManager
,
Context.LAYOUT_INFLATER_SERVICE
,
LayoutInflater
,
Context.ACTIVITY_SERVICE
,
ActivityManager
,
Context.POWER_SERVICE
,
PowerManager
,
Context.ALARM_SERVICE
,
AlarmManager
,
Context.NOTIFICATION_SERVICE
,
NotificationManager
,
Context.KEYGUARD_SERVICE
,
KeyguardManager
,
Context.LOCATION_SERVICE
,
LocationManager
,
Context.SEARCH_SERVICE
,
SearchManager
,
Context.SENSOR_SERVICE
,
SensorManager
,
Context.STORAGE_SERVICE
,
StorageManager
,
Context.VIBRATOR_SERVICE
,
Vibrator
,
Context.CONNECTIVITY_SERVICE
,
ConnectivityManager
,
Context.WIFI_SERVICE
,
WifiManager
,
Context.AUDIO_SERVICE
,
AudioManager
,
Context.MEDIA_ROUTER_SERVICE
,
MediaRouter
,
Context.TELEPHONY_SERVICE
,
TelephonyManager
,
Context.TELEPHONY_SUBSCRIPTION_SERVICE
,
SubscriptionManager
,
Context.CARRIER_CONFIG_SERVICE
,
CarrierConfigManager
,
Context.INPUT_METHOD_SERVICE
,
InputMethodManager
,
Context.UI_MODE_SERVICE
,
UiModeManager
,
Context.DOWNLOAD_SERVICE
,
DownloadManager
,
Context.BATTERY_SERVICE
,
BatteryManager
,
Context.JOB_SCHEDULER_SERVICE
,
JobScheduler
,
Context.NETWORK_STATS_SERVICE
,
NetworkStatsManager
,
HardwarePropertiesManager
,
Context.HARDWARE_PROPERTIES_SERVICE
public final IBinder onBind(Intent intent)
onBind
in class Service
intent
- The Intent that was used to bind to this service,
as given to Context.bindService
. Note that any extras that were included with
the Intent at that point will not be seen here.