Sunday, October 10, 2010

Implementation of the API cross-app.

Comments off topics share 15 September-: development with the SDK software webOS - enda

A little neat webOS is the ability to distribute a scene from another application on top of your stack applications.Certains core applications that have this feature are people (which is a cross-launching application contacts), picker camera capture and video player.

Are the key benefits of do it is:

Having does not time to start another application using the application manager (waiting on startup, etc.). andNot losing the context of the navigation of your application, i.e., the user should minimize or close the application was launched and then reselect your application. A magnetic "back" to return to the previous stage will do.

In this post, I'll show how to add this functionality to your application.Je will start by creating two applications. The first, A JPA, will be the "Launcher" application.This application from cross-app, API will push a B application scene in his stack, showing the information passed to the JPA has. If application B is launched from the launcher the same scene will display information about the b application.

Both applications are simple: I used the helloworld application template to create applications and two changes.In the appinfo.json, only changing a standard application is B application has "noWindow": true.B application stops to be launched on a new stage when pushed into another .the application ' another obvious difference is that the B application can be started with parameters, where A application is impossible, therefore to manage that I replaced the Assistant stage with an Assistant application.

If two applications are normally launched from the Launcher they operate the same - the first sequence is extensive and application information are displays (see images on the left and Centre above) .in this case is the application title, ID, and version.However, if "Start Cross" button in the application A is exploited, it will push the stage application B to his stack (picture right above).

FirstAssistant.prototype.handleButtonPressed = function (event) {var args = {AppID: "com.palmdts.appb", name: "first"}; var params = {title: Mojo.appInfo.title, id: Mojo.appInfo.id, version: Mojo.appInfo.version}; this.controller.stageController.pushScene (args, params);}

The magic happens in the call to pushScene; instead of simply specify the name of usual stage push, he spent two objets.Le first parameter contains the name and ID app application, we want to launch croisées.Dans this example, we are launching the first stage B application, and the second parameter contains the information we want to transmit.

When B application is launched traversed, parameters are passed to the stage as they would be transmitted by a scene in its own application - in the constructeur.En taking a look at the code, you can see that what is shown in the stage depends on whether or not something was passed.

function FirstAssistant (args) {this.launchParams = {}; if (args) {this.launchParams = args; this.str1 = ' this application was launched by another application!'; this.str2 = 'Passed for Launcher app info';} else {this.launchParams.title = Mojo.appInfo.title this.launchParams.id = Mojo.appInfo.id this.launchParams.version = Mojo.appInfo.version; this.str1 = 'this application was launched from the Launcher'; this.str2 = 'Info Mojo for application B';}}

This is all that .j's published here on github code so you can try it yourself. fun you!


View the original article here

No comments:

Post a Comment