Class IntentDeclaration

java.lang.Object
com.codename1.intents.IntentDeclaration

public final class IntentDeclaration extends Object

Everything the framework knows about one declared intent.

The build-time processor turns each AppIntent method into one of these and bakes it into the generated registry, so the list is fixed by the time the app runs -- which is exactly what the platforms require, since their intent catalogues are compiled into the native binary.

Applications read declarations through Intents.getDeclarations(); the simulator's Intents window is built entirely from them, so what a developer sees there is what actually shipped.

  • Constructor Details

    • IntentDeclaration

      public IntentDeclaration(String id, String title, String description, boolean headless, boolean discoverable, boolean destructive, String opensRoute, int timeoutSeconds, List<String> phrases, List<IntentParameterInfo> parameters, List<Exposure> exposure)
      Framework entry point: builds a declaration. Called by generated code and for a DynamicIntent; applications do not construct these.
  • Method Details

    • getId

      public String getId()
      The stable id the platform and the wire format use.
    • getTitle

      public String getTitle()
      The human-readable name shown in the Shortcuts app and the simulator.
    • getDescription

      public String getDescription()
      The longer explanation shown alongside the title, or an empty string.
    • isHeadless

      public boolean isHeadless()
      True when this intent is allowed to run without bringing the app to the foreground. See the package documentation for what a headless handler may and may not touch.
    • runsHeadless

      public boolean runsHeadless()

      True when an invocation of this intent actually runs with no window.

      Not the same question as isHeadless(), which reports what the declaration said. An intent that names a route is foregrounded however it was declared, because the route has to open somewhere a person can see -- iOS decides that statically through openAppWhenRun, and every Java caller has to reach the same answer.

      It exists because that combination was resolved separately in four places -- the Android trampoline, the service's post-bootstrap recheck, the parked-request path and the shortcut generator -- and each was fixed as its own bug. One definition, one answer.

    • isDiscoverable

      public boolean isDiscoverable()
      True when the platform may offer this intent before the user has ever run it. A false value means the intent only appears after a donation.
    • isDestructive

      public boolean isDestructive()
      True when the platform should confirm with the user before running this.
    • getOpensRoute

      public String getOpensRoute()
      The route template this intent navigates to, or an empty string. A non-empty value is what makes the platform open the app when the intent runs.
    • getTimeoutSeconds

      public int getTimeoutSeconds()
      The handler's own time budget in seconds, before the framework gives up and reports a failure to the platform.
    • getPhrases

      public List<String> getPhrases()
      The spoken phrases that invoke this intent. Empty on platforms that have no voice invocation, and empty for intents that never declared any.
    • getParameters

      public List<IntentParameterInfo> getParameters()
      The declared parameters, in the order the handler takes them.
    • getExposure

      public List<Exposure> getExposure()
      The consumers this intent is offered to.
    • isExposedTo

      public boolean isExposedTo(Exposure e)

      True when this intent is offered to the given consumer.

      Parameters
      • e: the consumer to test
    • getParameter

      public IntentParameterInfo getParameter(String name)

      The parameter with this name, or null.

      Parameters
      • name: the parameter name
    • toString

      public String toString()
      Description copied from class: Object
      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())
      Overrides:
      toString in class Object