Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

BB10: Invoke an app

In your bar-descriptor file, add:

  <invoke-target id="com.o2interactive.magellan.compass.app">
    <type>APPLICATION</type>
       <filter>
             <action>bb.action.OPEN</action>
             <mime-type>application/x-rtg</mime-type>
             <mime-type>application/x-rtd</mime-type>
             <property var="uris" value="file://"/>
             <property var="exts" value="rtd,rtg"/>
       </filter>
  </invoke-target>

 This is your "target" app.  The id in the invoke-target node has to be unique, and you can see in this case, I used a reverse DNS notation.  It also has ".app" at the end since this is an invocation of the entire app based on the type "APPLICATION".

 

Here, aslo, I have some file extensions the app can open.  Have not been able to test this, since my client app can not query the invocation framework just yet.

 

In the client app, do this:

var request :InvokeRequest = new InvokeRequest();
request.action = InvokeAction.OPEN;
request.target = 'com.o2interactive.magellan.compass.app';
			
InvokeManager.invokeManager.invoke( request );

 

To have the app to be a viewer in the client app (embed the app), add this to the bar-descriptor.xml file:

  <invoke-target id="com.o2interactive.magellan.compass.viewer">
    <type>VIEWER</type>
       <filter>
             <action>bb.action.OPEN</action>
             <mime-type>application/x-map</mime-type>
       </filter>
  </invoke-target>

 You can see the ID id slightly different, but the ID's have to be unique in the file or you get an error.

 

To embed the app in your client app, do this:

var request :InvokeViewerRequest = new InvokeViewerRequest();
request.action = InvokeAction.OPEN;
request.target = 'com.o2interactive.magellan.compass.viewer';
request.windowId = 'auniqueid';
request.windowHeight = 1000;
request.windowWidth = 700;
			
this.map_card = InvokeManager.invokeManager.invokeViewer( request );
this.map_card.x = 10;
this.map_card.y = 10;
this.map_card.resize( 500, 500 );
this.map_card.zOrder = 10;
this.map_card.visible = true;
this.map_card.addEventListener(ViewerEvent.VIEWER_CREATED, Created );

 The map_card is of type Viewer and gets instantiated from the invokeViewer request.  It does not get added to the display list since it is a portal into the target app, so you need to manage that like you do if you did a web view.

 

The windowId for the request just needs to be something unique.

 

Hope this helps.

Developer
DachFlach
Posts: 148
Registered: ‎12-06-2010
My Device: Not Specified

Re: BB10: Invoke an app

What would be different to invoke the app from a URL?

Such as, opening the app from a link in an email.

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: BB10: Invoke an app

That cannot be done. You cannot access an app in its own sandbox.
Developer
DachFlach
Posts: 148
Registered: ‎12-06-2010
My Device: Not Specified

Re: BB10: Invoke an app

So unlike Android, we cannot receive a link in an email, determine that the URL's domain is the same ID as a particular app and ask the User to either open the link in a browser  or  that app?

 

When I say receive the link in an email, I mean in the Messages app..  not the app in development.

 

Sorry for assuming this was an option. I sure hope it becomes one for PlayBook / BB10.

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: BB10: Invoke an app

If you have an app world ID, you can open the app store location that is in app world, otherwise you need to have the app id and do a direct invocation to it. So, you can do what you are asking, you just need to have the app id to it and write a few lines of code to invoke it. But it is not a URL that can be used in a browser. BB is a lot more secure than Android and the you can do a lot more with the invocation framework than you could with simple URLs.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: BB10: Invoke an app

Finally getting into the invocation stuff. This stuff is really cool! Everyone should consider at least making their app a target, if nothing else, just to open your app. I hope to post more information in case it helps others. If you do have a more complicated app, strongly suggest in making a "driver app" that acts like a client to your main app (the target).

Also, if you plan to invoke (client side) other app services (targets) that might be more universal (contacts, calendar, maps), it will probably be best to prepare that RIM apps will take priority over 3rd party apps (it was mentioned during a couple of JAMS). To get around this, the client app can have a preference to allow the user to select which target to use and then do a direct invocation.
Developer
apman
Posts: 194
Registered: ‎11-12-2010
My Device: Not Specified

Re: BB10: Invoke an app

How can we find out the ID of built-in apps? 

Specifically I would like to invoke the Voice Note recorder (assuming that's still going to be in BB10).

 

 


My app : Get set - Get up!   Get ready for the snooze revolution.

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: BB10: Invoke an app

All that information should be posted by RIM in the next couple of weeks. Ideally, you want to invoke the generalized mime-type of the app (which should also be posted soon), so if someone creates a better voice note application, then you can then leverage that app instead (or let the consumer decide with a preference setting).
Developer
apman
Posts: 194
Registered: ‎11-12-2010
My Device: Not Specified

Re: BB10: Invoke an app


jtegen wrote:
[...] Ideally, you want to invoke the generalized mime-type of the app [...]

Good point, which reminds me of another question: do you know how to request something back from the app you invoke? Say, I wanted to launch your compass to get the direction that my user is pointing their device in ... or in my case, I want them to record something and get a reference to the new file back (if I specifically ask for the built-in voice recorder I can get around that by just picking the latest file saved in the default save location, but other apps might save in other locations)

 

Presumably I'd have to use <type>card.composer</type> in the bar-descriptor and then maybe something like InvokeRequest.fileTransferMode = FileTransferMode.LINK  ....?  or 

InvokeManager.invokeManager.viewerSendMessage()   ... but what message?

 

Still pretty much tapping in the dark ... but maybe things get clearer with the new info coming from RIM - I really hope they include some samples and/or a decent high-level overview of what's what in the API ...

 

Thanks

Anna

 


My app : Get set - Get up!   Get ready for the snooze revolution.

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: BB10: Invoke an app

Each app will need to pubish there schema. A lot of this will be based on the standard apps that RIM will provide. So if you are replacing a RIM provided app, you will need to follow the same schema. Of couse you can extend a schema, and possibly only provide a part of the default schema, but the parts you do provide, would have to be the same.

RIM mentioned at a JAM that these schemas would be posted and that 3rd party apps would be able to post their own schemas to allow for full inter-operability.