|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object android.content.Context android.content.ContextWrapper android.app.Service mobi.voiceassistant.base.IntentExecutorService mobi.voiceassistant.base.Agent
public abstract class Agent
Base class for implementing agents
Field Summary | |
---|---|
static String |
ARG_REQUEST
|
static String |
ARG_RESPONSE
|
Fields inherited from class android.app.Service |
---|
START_CONTINUATION_MASK, START_FLAG_REDELIVERY, START_FLAG_RETRY, START_NOT_STICKY, START_REDELIVER_INTENT, START_STICKY, START_STICKY_COMPATIBILITY |
Fields inherited from interface android.content.ComponentCallbacks2 |
---|
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 Summary | |
---|---|
Agent()
|
Method Summary | |
---|---|
protected void |
goBackground(Bundle args,
int requestCode)
Call this method if you want to continue computation on background thread. |
protected void |
goBackground(Request request,
Response response,
int requestCode)
Call this method if you want to continue computation on background thread. |
protected void |
onBackground(Bundle args,
int requestCode)
Override this method if you called goBackground(android.os.Bundle, int) . |
protected void |
onBackground(Request request,
Response response,
int requestCode)
Override this method if you called goBackground(Request, Response, int) . |
protected abstract void |
onCommand(Request request)
Override this method to handle voice commands for this agent issued by user. |
protected void |
onExecute(Intent bindIntent,
Intent intent)
|
protected void |
onModalCancel(Request request)
Override this method if you called Response.enterModalScope(int)
(or it's variants). |
protected void |
onModalFail(Request request)
Override this method if you called Response.enterModalScope(int)
(or it's variants). |
protected void |
onRequest(String action,
Request request)
Override this method if you use custom actions for PendingRequest . |
Methods inherited from class mobi.voiceassistant.base.IntentExecutorService |
---|
onBind |
Methods inherited from class android.app.Service |
---|
dump, getApplication, onConfigurationChanged, onCreate, onDestroy, onLowMemory, onRebind, onStart, onStartCommand, onTaskRemoved, onTrimMemory, onUnbind, startForeground, stopForeground, stopSelf, stopSelf, stopSelfResult |
Methods inherited from class android.content.Context |
---|
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ARG_REQUEST
public static final String ARG_RESPONSE
Constructor Detail |
---|
public Agent()
Method Detail |
---|
protected abstract void onCommand(Request request)
Request
with AgentContract.Intents.ACTION_COMMAND
arrives.
Inside this method Request.getContent()
returns instance of Token
and
Request.getDispatchId()
returns id
of command in corresponding module.
Note that this method called on main thread.
onModalCancel(Request)
,
onModalFail(Request)
protected void onModalFail(Request request)
Response.enterModalScope(int)
(or it's variants).
When user says something that cannot be matched by any pattern in modal module this method is
called.
Note that this method called on main thread.
Default implementation throws UnsupportedOperationException
.
onCommand(Request)
,
onModalFail(Request)
protected void onModalCancel(Request request)
Response.enterModalScope(int)
(or it's variants). Default implementation throws UnsupportedOperationException
.
Note that this method called on main thread.
onCommand(Request)
,
onModalFail(Request)
protected void onBackground(Request request, Response response, int requestCode)
goBackground(Request, Response, int)
.
Default implementation throws UnsupportedOperationException
.
request
- Request passed to goBackground(Request, Response, int)
.response
- Response passed to goBackground(Request, Response, int)
.requestCode
- Code passed to goBackground(Request, Response, int)
.protected void onBackground(Bundle args, int requestCode)
goBackground(android.os.Bundle, int)
.
Default implementation calls onBackground(Request, Response, int)
.
args
- Bundle passed to goBackground(android.os.Bundle, int)
.requestCode
- Code passed to goBackground(android.os.Bundle, int)
.protected void onExecute(Intent bindIntent, Intent intent)
onExecute
in class IntentExecutorService
protected void onRequest(String action, Request request)
PendingRequest
.
Default implementation calls onCommand(Request)
for AgentContract.Intents.ACTION_COMMAND
,
onModalFail(Request)
for AgentContract.Intents.ACTION_MODAL_FAIL
and
onModalCancel(Request)
for AgentContract.Intents.ACTION_MODAL_CANCEL
action
- The action from Request.getAction()
request
- The request itselfprotected final void goBackground(Request request, Response response, int requestCode)
onBackground(Request, Response, int)
.
request
- Request passed to onBackground(Request, Response, int)
.response
- Response passed to onBackground(Request, Response, int)
.requestCode
- Code passed to onBackground(Request, Response, int)
.protected final void goBackground(Bundle args, int requestCode)
onBackground(android.os.Bundle, int)
.
args
- Bundle passed to onBackground(android.os.Bundle, int)
.requestCode
- Code passed to onBackground(android.os.Bundle, int)
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |