public final class DynamicIntent
- Object
- DynamicIntent
A named parameterization of an intent your application already declares – “reorder my usual”, “call Mum” – built from data only known at runtime.
Map<String, Object> usual = new HashMap<String, Object>();
usual.put("shop", "shop-7");
usual.put("size", "large");
Intents.registerDynamicIntent(new DynamicIntent("usual_coffee", "order_coffee",
"Order my usual").bind(usual));
Why it must name a base intent
It runs by running the intent it names, with the bound values filled in. It cannot introduce a new capability: the native catalogue is compiled into the app, so a genuinely new verb could never reach the platform, and a runtime API that appeared to add one would work in the simulator and silently do nothing on a device.
Binding to a base intent is also what makes it invokable at all – there is a handler to run, which is the whole point of registering it.
Constructors
public DynamicIntent(String id, String baseIntentId, String title) | Creates a parameterization. |
Methods
Inherited methods
Constructor details
DynamicIntent
public DynamicIntent(String id, String baseIntentId, String title)Creates a parameterization.
Parameters
idString- the id this parameterization is known by; must not collide with a declared intent
baseIntentIdString- the declared intent that actually runs
titleString- the name shown to the user
Method details
bind
public DynamicIntent bind(Map<String, Object> params)Binds values for the base intent’s parameters. Anything supplied at
invocation time wins, so a bound value is a default rather than a lock.
Parameters
paramsMap<String, Object>- the values to bind
Returns
this parameterization, for chaining
bind
public DynamicIntent bind(String name, Object value)Binds one value.
Parameters
nameString- the parameter name
valueObject- the value to bind
Returns
this parameterization, for chaining
getId
public String getId()getBaseIntentId
public String getBaseIntentId()The declared intent this runs.
getTitle
public String getTitle()getBoundParameters
public Map<String, Object> getBoundParameters()The bound values, never null.
toString
public String toString()Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + ‘@’ + Integer.toHexString(hashCode())