Most visited

Recently visited

Added in API level 21

VoiceInteractionSessionService

public abstract class VoiceInteractionSessionService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.service.voice.VoiceInteractionSessionService


An active voice interaction session, initiated by a VoiceInteractionService.

Summary

Inherited constants

From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2

Public constructors

VoiceInteractionSessionService()

Public methods

IBinder onBind(Intent intent)

Return the communication channel to the service.

void onConfigurationChanged(Configuration newConfig)

Called by the system when the device configuration changes while your component is running.

void onCreate()

Called by the system when the service is first created.

void onLowMemory()

This is called when the overall system is running low on memory, and actively running processes should trim their memory usage.

abstract VoiceInteractionSession onNewSession(Bundle args)
void onTrimMemory(int level)

Called when the operating system has determined that it is a good time for a process to trim unneeded memory from its process.

Protected methods

void dump(FileDescriptor fd, PrintWriter writer, String[] args)

Print the Service's state into the given stream.

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.content.ComponentCallbacks

Public constructors

VoiceInteractionSessionService

Added in API level 21
VoiceInteractionSessionService ()

Public methods

onBind

Added in API level 21
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.

onConfigurationChanged

Added in API level 21
void onConfigurationChanged (Configuration newConfig)

Called by the system when the device configuration changes while your component is running. Note that, unlike activities, other components are never restarted when a configuration changes: they must always deal with the results of the change, such as by re-retrieving resources.

At the time that this function has been called, your Resources object will have been updated to return resource values matching the new configuration.

For more information, read Handling Runtime Changes.

Parameters
newConfig Configuration: The new device configuration.

onCreate

Added in API level 21
void onCreate ()

Called by the system when the service is first created. Do not call this method directly.

onLowMemory

Added in API level 21
void onLowMemory ()

This is called when the overall system is running low on memory, and actively running processes should trim their memory usage. While the exact point at which this will be called is not defined, generally it will happen when all background process have been killed. That is, before reaching the point of killing processes hosting service and foreground UI that we would like to avoid killing.

You should implement this method to release any caches or other unnecessary resources you may be holding on to. The system will perform a garbage collection for you after returning from this method.

Preferably, you should implement onTrimMemory(int) from ComponentCallbacks2 to incrementally unload your resources based on various levels of memory demands. That API is available for API level 14 and higher, so you should only use this onLowMemory() method as a fallback for older versions, which can be treated the same as onTrimMemory(int) with the TRIM_MEMORY_COMPLETE level.

onNewSession

Added in API level 21
VoiceInteractionSession onNewSession (Bundle args)

Parameters
args Bundle
Returns
VoiceInteractionSession

onTrimMemory

Added in API level 21
void onTrimMemory (int level)

Called when the operating system has determined that it is a good time for a process to trim unneeded memory from its process. This will happen for example when it goes in the background and there is not enough memory to keep as many background processes running as desired. You should never compare to exact values of the level, since new intermediate values may be added -- you will typically want to compare if the value is greater or equal to a level you are interested in.

To retrieve the processes current trim level at any point, you can use ActivityManager.getMyMemoryState(RunningAppProcessInfo).

Parameters
level int: The context of the trim, giving a hint of the amount of trimming the application may like to perform. May be TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_UI_HIDDEN, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, or TRIM_MEMORY_RUNNING_MODERATE.

Protected methods

dump

Added in API level 21
void dump (FileDescriptor fd, 
                PrintWriter writer, 
                String[] args)

Print the Service's state into the given stream. This gets invoked if you run "adb shell dumpsys activity service <yourservicename>" (note that for this command to work, the service must be running, and you must specify a fully-qualified service name). This is distinct from "dumpsys <servicename>", which only works for named system services and which invokes the dump(FileDescriptor, String[]) method on the IBinder interface registered with ServiceManager.

Parameters
fd FileDescriptor: The raw file descriptor that the dump is being sent to.
writer 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.

Hooray!