pushScene (sceneArguments)
Pushes a new scene, passing in the optional sceneArguments.
sceneArguments can be any number of arguments of any type. They are simply passed through to the target scene.
Example usage:
StageAssistant.prototype.setup = function() {
Mojo.Controller.stageController.pushScene ("first");
}
Cross-App Launch
You can also in some situations push a scene from another application onto your application's stack for a faster, more seamless transition between apps. This is especially useful if the other application is being used simply to gather a piece of data to be returned to the calling application.
This example shows how you could use the Camera application within your application through a cross-app launch. This requires that you call thepushScene method just as with any scene push, but include sceneArguments that indicate an application launch is required:
this.someAssistant.stageController.pushScene(
{appId :'com.palm.app.camera', name: 'capture'},
{sublaunch : true}
);
When the picture is taken or canceled, control will be returned back to your scene with a call to the scene's activatemethod, just as with any scene pop. However, unlike the typical scene lifecycle, there will be a response object passed as an argument to the activate method:
CameraAssistant.prototype.activate = function(response){
if (response) {
if (response.returnValue) {
this.showDialogBox('Picture Taken', response.filename);
} else {
this.showDialogBox('No Picture', "");
}
} else {
Mojo.Log.info("Picture not requested");
}
};
This example demonstrates launching the People Picker to allow the user to select a contact and return that contact's information to the calling application:
PeoplePickerAssistant.prototype.getContact = function(event){
this.contactRequest = true;
this.controller.stageController.pushScene(
{ appId :'com.palm.app.contacts', name: 'list' },
{ mode: 'picker', message: "headerMessage" }
);
};
After the user makes a selection from the list, the details are returned to the the calling application through the scene's activate method:
PeoplePickerAssistant.prototype.activate = function(response){
if (response) {
if (response.personId) {
this.showDialogBox('Contact Received', response.personId);
} else {
this.showDialogBox('Contact Request Failed', "");
}
} else {
Mojo.Log.info("No Contact Requested");
}
};







Friday, 15 January 2010