Card invocation

Cards enhance the invocation framework's capabilities by allowing applications to share the UI and the application logic with other applications. You send a request to invoke a card in the same way as an invocation request for an application, which means that everything that you learned about sending an invocation request applies to cards as well.

Here's how you can use the invocation framework to import a card from another application:

var request:InvokeRequest = new InvokeRequest(); = "com.example.myapp";
request.action = InvokeAction.VIEW;
request.uri = "file://path/to/document.pdf";
InvokeManager.invokeManager.invoke( request );

Before a new card is invoked and allowed to be stacked, the platform verifies that the client application is not already parenting a card. Unlike an application, a card may continue to exist in multiple instances, but a parent application (or a card) can parent only one card at a time. This is important to consider, since multiple instances of a card may be running at the same time.

Cards support a "fire and forget" import model. However, for applications that require notifications and additional feedback, cards also provide peek notifications and response data.

Listen for peek events

Cards offer a parent card or an application the ability to receive notifications when a user peeks at another card. This is important if you want your application to display content differently during a peek event. Here is how you can enable your application to listen for peek events:

(CardPeekEvent.PEEK_BEGIN, onPeekBegin);
(CardPeekEvent.PEEK_END, onPeekEnd);

Listen for a card response message

A card can send a response message to the parent application when a card completes its task. For example, a picker card can return the data, that a user selects, to the client application. Here's how you can listen for card response messages:

(CardCloseEvent.CARD_CLOSED, onCardClosed );

Typical card usage for previewers and many composers does not involve a response. Therefore, a best practice is to design your previewer and composer cards in such a way that any response is optional.

Close a card

An application may request to close a card that it imported. As a result the card is transitioned off screen. When a user closes the card, both the application and the card are notified. However, if the card is closed by the application itself, the card cannot provide a response. Also, when an application closes a card, it closes the entire stack of cards (including children of the card) above it. Here's how your application can request to close a child card: