public class ManagedApplicationService extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
ManagedApplicationService.BinderChecker
Implement to validate returned IBinder instance.
|
static interface |
ManagedApplicationService.PendingEvent
Implement to call IInterface methods after service is connected.
|
Modifier and Type | Method and Description |
---|---|
static ManagedApplicationService |
build(Context context,
ComponentName component,
int userId,
int clientLabel,
String settingsAction,
ManagedApplicationService.BinderChecker binderChecker)
Create a new ManagedApplicationService object but do not yet bind to the user service.
|
void |
connect()
Asynchronously bind to the application service if not bound.
|
void |
disconnect()
Asynchronously unbind from the application service if bound.
|
boolean |
disconnectIfNotMatching(ComponentName componentName,
int userId)
Asynchronously unbind from the application service if the bound service component and user
does not match the given signature.
|
ComponentName |
getComponent() |
int |
getUserId() |
void |
sendEvent(ManagedApplicationService.PendingEvent event)
Send an event to run as soon as the binder interface is available.
|
public static ManagedApplicationService build(Context context, ComponentName component, int userId, int clientLabel, String settingsAction, ManagedApplicationService.BinderChecker binderChecker)
context
- a Context to use for binding the application service.component
- the ComponentName
of the application service to bind.userId
- the user ID of user to bind the application service as.clientLabel
- the resource ID of a label displayed to the user indicating the
binding service.settingsAction
- an action that can be used to open the Settings UI to enable/disable
binding to these services.binderChecker
- an interface used to validate the returned binder object.public int getUserId()
public ComponentName getComponent()
public boolean disconnectIfNotMatching(ComponentName componentName, int userId)
componentName
- the component that must match.userId
- the user ID that must match.true
if not matching.public void sendEvent(ManagedApplicationService.PendingEvent event)
event
- a ManagedApplicationService.PendingEvent
to send.public void disconnect()
public void connect()