AbstractInputMethodService
public
abstract
class
AbstractInputMethodService
extends Service
implements
KeyEvent.Callback
| java.lang.Object | ||||
| ↳ | android.content.Context | |||
| ↳ | android.content.ContextWrapper | |||
| ↳ | android.app.Service | |||
| ↳ | android.inputmethodservice.AbstractInputMethodService | |||
|
Known direct subclasses
|
AbstractInputMethodService provides a abstract base class for input methods.
Normal input method implementations will not derive from this directly,
instead building on top of InputMethodService or another more
complete base class. Be sure to read InputMethod for more
information on the basics of writing input methods.
This class combines a Service (representing the input method component to the system with the InputMethod interface that input methods must implement. This base class takes care of reporting your InputMethod from the service when clients bind to it, but provides no standard implementation of the InputMethod interface itself. Derived classes must implement that interface.
After Build.VERSION_CODES.S, the maximum possible area to show the soft
input may not be the entire screen. For example, some devices may support to show the soft input
on only half of screen.
In that case, moving the soft input from one half screen to another will trigger a
Resources update to match the new Configuration and
this AbstractInputMethodService may also receive a
Service.onConfigurationChanged(android.content.res.Configuration) callback if there's notable configuration changes
See also:
Summary
Nested classes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
class |
AbstractInputMethodService.AbstractInputMethodImpl
Base class for derived classes to implement their |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class |
AbstractInputMethodService.AbstractInputMethodSessionImpl
Base class for derived classes to implement their |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Inherited constants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
From class
android.app.Service
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From class
android.content.Context
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From interface
android.content.ComponentCallbacks2
|
Public constructors | |
|---|---|
AbstractInputMethodService()
|
|
Public methods | |
|---|---|
KeyEvent.DispatcherState
|
getKeyDispatcherState()
Return the global |
Object
|
getSystemService(String name)
Return the handle to a system-level service by name. |
final
IBinder
|
onBind(Intent intent)
Return the communication channel to the service. |
abstract
AbstractInputMethodService.AbstractInputMethodImpl
|
onCreateInputMethodInterface()
Called by the framework during initialization, when the InputMethod interface for this service needs to be created. |
abstract
AbstractInputMethodService.AbstractInputMethodSessionImpl
|
onCreateInputMethodSessionInterface()
Called by the framework when a new InputMethodSession interface is needed for a new client of the input method. |
void
|
onDestroy()
Called by the system to notify a Service that it is no longer used and is being removed. If you override this method you must call through to the superclass implementation. |
boolean
|
onGenericMotionEvent(MotionEvent event)
Implement this to handle generic motion events on your input method. |
boolean
|
onTrackballEvent(MotionEvent event)
Implement this to handle trackball events on your input method. |
Protected methods | |
|---|---|
void
|
dump(FileDescriptor fd, PrintWriter fout, String[] args)
Implement this to handle |
Inherited methods | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
From class
android.app.Service
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From class
android.content.ContextWrapper
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From class
android.content.Context
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From class
java.lang.Object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From interface
android.content.ComponentCallbacks2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From interface
android.view.KeyEvent.Callback
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From interface
android.content.ComponentCallbacks
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Public constructors
AbstractInputMethodService
public AbstractInputMethodService ()
Public methods
getKeyDispatcherState
public KeyEvent.DispatcherState getKeyDispatcherState ()
Return the global KeyEvent.DispatcherState
for used for processing events from the target application.
Normally you will not need to use this directly, but
just use the standard high-level event callbacks like KeyEvent.Callback.onKeyDown(int, KeyEvent).
| Returns | |
|---|---|
KeyEvent.DispatcherState |
|
getSystemService
public Object getSystemService (String name)
Return the handle to a system-level service by name. The class of the returned object varies by the requested name. Currently available names are:
-
WINDOW_SERVICE("window") - The top-level window manager in which you can place custom
windows. The returned object is a
WindowManager. Must only be obtained from a visual context such as Activity or a Context created withcreateWindowContext(int, android.os.Bundle), which are adjusted to the configuration and visual bounds of an area on screen. -
LAYOUT_INFLATER_SERVICE("layout_inflater") - A
LayoutInflaterfor inflating layout resources in this context. Must only be obtained from a visual context such as Activity or a Context created withcreateWindowContext(int, android.os.Bundle), which are adjusted to the configuration and visual bounds of an area on screen. -
ACTIVITY_SERVICE("activity") - A
ActivityManagerfor interacting with the global activity state of the system. -
WALLPAPER_SERVICE("wallpaper") - A
WallpaperServicefor accessing wallpapers in this context. Must only be obtained from a visual context such as Activity or a Context created withcreateWindowContext(int, android.os.Bundle), which are adjusted to the configuration and visual bounds of an area on screen. -
POWER_SERVICE("power") - A
PowerManagerfor controlling power management. -
ALARM_SERVICE("alarm") - A
AlarmManagerfor receiving intents at the time of your choosing. -
NOTIFICATION_SERVICE("notification") - A
NotificationManagerfor informing the user of background events. -
KEYGUARD_SERVICE("keyguard") - A
KeyguardManagerfor controlling keyguard. -
LOCATION_SERVICE("location") - A
LocationManagerfor controlling location (e.g., GPS) updates. -
SEARCH_SERVICE("search") - A
SearchManagerfor handling search. -
VIBRATOR_MANAGER_SERVICE("vibrator_manager") - A
VibratorManagerfor accessing the device vibrators, interacting with individual ones and playing synchronized effects on multiple vibrators. -
VIBRATOR_SERVICE("vibrator") - A
Vibratorfor interacting with the vibrator hardware. -
CONNECTIVITY_SERVICE("connectivity") - A
ConnectivityManagerfor handling management of network connections. -
IPSEC_SERVICE("ipsec") - A
IpSecManagerfor managing IPSec on sockets and networks. -
WIFI_SERVICE("wifi") - A
WifiManagerfor 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. -
WIFI_AWARE_SERVICE("wifiaware") - A
WifiAwareManagerfor management of Wi-Fi Aware discovery and connectivity. -
WIFI_P2P_SERVICE("wifip2p") - A
WifiP2pManagerfor management of Wi-Fi Direct connectivity. -
INPUT_METHOD_SERVICE("input_method") - An
InputMethodManagerfor management of input methods. -
UI_MODE_SERVICE("uimode") - An
UiModeManagerfor controlling UI modes. -
DOWNLOAD_SERVICE("download") - A
DownloadManagerfor requesting HTTP downloads -
BATTERY_SERVICE("batterymanager") - A
BatteryManagerfor managing battery state -
JOB_SCHEDULER_SERVICE("taskmanager") - A
JobSchedulerfor managing scheduled tasks -
NETWORK_STATS_SERVICE("netstats") - A
NetworkStatsManagerfor querying network usage statistics. -
HARDWARE_PROPERTIES_SERVICE("hardware_properties") - A
HardwarePropertiesManagerfor accessing hardware properties. -
DOMAIN_VERIFICATION_SERVICE("domain_verification") - A
DomainVerificationManagerfor accessing web domain approval state.
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.)
Note: Instant apps, for which PackageManager#isInstantApp() returns true,
don't have access to the following system services: DEVICE_POLICY_SERVICE,
FINGERPRINT_SERVICE, KEYGUARD_SERVICE, SHORTCUT_SERVICE,
USB_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE,
WIFI_SERVICE, WIFI_AWARE_SERVICE. For these services this method will
return null. Generally, if you are running as an instant app you should always
check whether the result of this method is null.
Note: When implementing this method, keep in mind that new services can be added on newer
Android releases, so if you're looking for just the explicit names mentioned above, make sure
to return null when you don't recognize the name — if you throw a
RuntimeException exception instead, you're app might break on new Android releases.
| Parameters | |
|---|---|
name |
String: This value cannot be null.
|
| Returns | |
|---|---|
Object |
The service or null if the name does not exist. |
onBind
public final IBinder onBind (Intent intent)
Return the communication channel to the service. May return null if
clients can not bind to the service. The returned
IBinder is usually for a complex interface
that has been described using
aidl.
Note that unlike other application components, calls on to the IBinder interface returned here may not happen on the main thread of the process. More information about the main thread can be found in Processes and Threads.
| Parameters | |
|---|---|
intent |
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. |
| Returns | |
|---|---|
IBinder |
Return an IBinder through which clients can call on to the service. |
onCreateInputMethodInterface
public abstract AbstractInputMethodService.AbstractInputMethodImpl onCreateInputMethodInterface ()
Called by the framework during initialization, when the InputMethod interface for this service needs to be created.
| Returns | |
|---|---|
AbstractInputMethodService.AbstractInputMethodImpl |
|
onCreateInputMethodSessionInterface
public abstract AbstractInputMethodService.AbstractInputMethodSessionImpl onCreateInputMethodSessionInterface ()
Called by the framework when a new InputMethodSession interface is needed for a new client of the input method.
| Returns | |
|---|---|
AbstractInputMethodService.AbstractInputMethodSessionImpl |
|
onDestroy
public void onDestroy ()
Called by the system to notify a Service that it is no longer used and is being removed. The service should clean up any resources it holds (threads, registered receivers, etc) at this point. Upon return, there will be no more calls in to this Service object and it is effectively dead. Do not call this method directly. If you override this method you must call through to the superclass implementation.
onGenericMotionEvent
public boolean onGenericMotionEvent (MotionEvent event)
Implement this to handle generic motion events on your input method.
| Parameters | |
|---|---|
event |
MotionEvent: The motion event being received. |
| Returns | |
|---|---|
boolean |
True if the event was handled in this function, false otherwise. |
See also:
onTrackballEvent
public boolean onTrackballEvent (MotionEvent event)
Implement this to handle trackball events on your input method.
| Parameters | |
|---|---|
event |
MotionEvent: The motion event being received. |
| Returns | |
|---|---|
boolean |
True if the event was handled in this function, false otherwise. |
See also:
Protected methods
dump
protected void dump (FileDescriptor fd, PrintWriter fout, String[] args)
Implement this to handle Binder.dump()
calls on your input method.
| Parameters | |
|---|---|
fd |
FileDescriptor: The raw file descriptor that the dump is being sent to. |
fout |
PrintWriter: The PrintWriter to which you should dump your state. This will be
closed for you after you return. |
args |
String: additional arguments to the dump request. |
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-10-27 UTC.