public class IntentUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
IntentUtils.FilterFormatException
Exception thrown when a call to one of the intent filter creation methods
encounters a problem with one or more arguments.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_ACTION_FORMAT
The default action name format to be used with
getActionListIntentFilter(java.lang.String, java.lang.String, java.lang.String...) . |
static java.lang.String |
TAG |
Constructor and Description |
---|
IntentUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
discoverAction(android.content.Intent sig)
Discovers the action inscribed into the intent, if any, and logs the
result before returning it to the caller.
|
static android.content.IntentFilter |
getActionListIntentFilter(java.lang.String sDomain,
java.util.Collection<java.lang.String> asActions)
Constructs an
IntentFilter for all actions that would be
assembled from the specified domain and action list. |
static android.content.IntentFilter |
getActionListIntentFilter(java.lang.String sDomain,
java.lang.String... asActions)
Constructs an
IntentFilter for all actions that would be
assembled from the specified domain and action list. |
static android.content.IntentFilter |
getActionListIntentFilter(java.lang.String sFormat,
java.lang.String sDomain,
java.util.Collection<java.lang.String> asActions)
Constructs an
IntentFilter for all actions that would be
assembled from the specified format string, domain, and action list. |
static android.content.IntentFilter |
getActionListIntentFilter(java.lang.String sCustomFormat,
java.lang.String sDomain,
java.lang.String... asActions)
Constructs an
IntentFilter for all actions that would be
assembled from the specified format string, domain, and action list. |
static android.content.Intent |
getBoundIntent(android.content.Context ctx,
java.lang.Class<?> cls)
Tries to get an
Intent that is bound to the specified class,
which is expected to process that intent. |
static android.content.Intent |
getBoundIntent(android.content.Context ctx,
java.lang.Class<?> cls,
java.lang.String sAction)
Tries to get an
Intent that is bound to the specified class,
which is expected to process that intent. |
public static final java.lang.String TAG
public static final java.lang.String DEFAULT_ACTION_FORMAT
getActionListIntentFilter(java.lang.String, java.lang.String, java.lang.String...)
. It has two placeholders; one for the
intent filter's "domain" and the other for each action token.public static java.lang.String discoverAction(android.content.Intent sig)
sig
- the intent to be examinedpublic static android.content.Intent getBoundIntent(android.content.Context ctx, java.lang.Class<?> cls)
Intent
that is bound to the specified class,
which is expected to process that intent. If the context is null, then
the method will still return an intent, but it will not be successfully
bound.ctx
- the context in which to create the intentcls
- the class that is expected to process the intentpublic static android.content.Intent getBoundIntent(android.content.Context ctx, java.lang.Class<?> cls, java.lang.String sAction)
Intent
that is bound to the specified class,
which is expected to process that intent. If the context is null, then
the method will still return an intent, but it will not be bound to the
specified class. That intent is then inscribed with a specific action.ctx
- the context in which to create the intentcls
- the class that is expected to process the intentsAction
- the action to be inscribed into the intentpublic static android.content.IntentFilter getActionListIntentFilter(java.lang.String sCustomFormat, java.lang.String sDomain, java.lang.String... asActions) throws IntentUtils.FilterFormatException
IntentFilter
for all actions that would be
assembled from the specified format string, domain, and action list.sCustomFormat
- a format string to be applied to the intent
domain and action namessDomain
- the domain under which the intents will be
recognized; this is typically a package or class nameasActions
- the list of actions to be written to the filterIntentUtils.FilterFormatException
- if the domain string or action list
is not usablepublic static android.content.IntentFilter getActionListIntentFilter(java.lang.String sFormat, java.lang.String sDomain, java.util.Collection<java.lang.String> asActions) throws IntentUtils.FilterFormatException
IntentFilter
for all actions that would be
assembled from the specified format string, domain, and action list.sFormat
- a format string to be applied to the intent domain
and action namessDomain
- the domain under which the intents will be
recognized; this is typically a package or class nameasActions
- the list of actions to be written to the filterIntentUtils.FilterFormatException
- if the domain string or action list
is not usablepublic static android.content.IntentFilter getActionListIntentFilter(java.lang.String sDomain, java.lang.String... asActions) throws IntentUtils.FilterFormatException
IntentFilter
for all actions that would be
assembled from the specified domain and action list.
Each action token is inserted along with the domain string into the
DEFAULT_ACTION_FORMAT
specification.sDomain
- the domain under which the intents will be recognized;
recognized; this is typically a package or class nameasActions
- the list of actions to be written to the filterIntentUtils.FilterFormatException
- if the domain string or action list
is unusablepublic static android.content.IntentFilter getActionListIntentFilter(java.lang.String sDomain, java.util.Collection<java.lang.String> asActions) throws IntentUtils.FilterFormatException
IntentFilter
for all actions that would be
assembled from the specified domain and action list.
Each action token is inserted along with the domain string into the
DEFAULT_ACTION_FORMAT
specification.sDomain
- the domain under which the intents will be
recognized; this is typically a package or class nameasActions
- the list of actions to be written to the filterIntentUtils.FilterFormatException
- if the domain string or action list
is unusable