public final class DynamicIntent

  1. Object
  2. 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

public DynamicIntent bind(Map<String, Object> params)Binds values for the base intent’s parameters.
public DynamicIntent bind(String name, Object value)Binds one value.
public String getId()
public String getBaseIntentId()The declared intent this runs.
public String getTitle()
public Map<String, Object> getBoundParameters()The bound values, never null.
public String toString()Returns a string representation of the object.

Inherited methods

Constructor details

DynamicIntent

public DynamicIntent(String id, String baseIntentId, String title)
Creates a parameterization.

Parameters

id String
the id this parameterization is known by; must not collide with a declared intent
baseIntentId String
the declared intent that actually runs
title String
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

params Map<String, Object>
the values to bind

Returns

this parameterization, for chaining

bind

public DynamicIntent bind(String name, Object value)
Binds one value.

Parameters

name String
the parameter name
value Object
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())