Mojo.Controller.SceneController.serviceRequest is a method used to launch many different service requests including Browser, Phone, Camera, Photos, Maps, Email, Calendar, Contacts and Messaging. See below for examples.
Examples:
Browser:
// webStory
//
// Launch the Browser when user taps a story; will launch original story URL
// or a tapped link within a webView
StoryViewAssistant.prototype.webStory = function(event) {
this.controller.serviceRequest('palm://com.palm.applicationManager', {
method: 'open',
parameters: {
id: 'com.palm.app.browser',
params: {
target: this.storyFeed.stories[this.storyIndex].url
}
}
});
};
Phone:
this.controller.serviceRequest('palm://com.palm.applicationManager', {
method: 'open',
parameters: {
target: "tel://4085556666"
}
});
Camera:
Palm states that you must use a Cross-App launch to call the Camera from your application. This is covered here.
Photos
this.controller.serviceRequest('palm://com.palm.applicationManager', {
method:'launch',
parameters: {
id:"com.palm.app.photos",
params: {}
}
});
Maps
this.controller.serviceRequest('palm://com.palm.applicationManager', {
method: 'launch',
parameters: {
id: 'com.palm.app.maps',
params: {
location: {lat: 37.759568992305134, lng: -122.39842414855957, acc: 1},
query: "Pizza"
}
}
});
This example demonstrates creation of an account; required before synergy services can be accessed. See this tutorial for a more detailed description of Synergy accounts.
this.controller.serviceRequest('palm://com.palm.accounts/crud', {
method: 'createAccount',
parameters: {
username: "myusername",
domain: "mydomain",
displayName: "My Name",
icons: {largeIcon: '../accountIcon.png', smallIcon: '../stampIcon.png'},
dataTypes: ["CONTACTS", "CALENDAR"],
isDataReadOnly: false
},
onSuccess: this.accountCreated.bind(this);
onFailure: function(response) {
Mojo.Log.info("Account create failed; ", response.errorText}
}
});
This example demonstrates adding a new contact entry:
this.controller.serviceRequest('palm://com.palm.contacts/crud', {
method: 'createContact',
parameters: {
accountId: this.accountId,
contact: {
firstName: "Ken",
lastName: "Young",
companyName: "www.webOShelp.net",
nickname: "webOS Newb"
}
},
onSuccess: this.successEvent.bind(this),
onFailure: this.failureHandler.bind(this)
});
People Picker
The People Picker, like the Camera, is also launched via a Cross-App launch. Click here for an example.
This example demonstrates the creation of a new calendar (requires Synergy Account ID):
CalendarAssistant.prototype.createCalendar = function() {
this.currentMethod = "Calendar - Create";
this.controller.serviceRequest('palm://com.palm.calendar/crud', {
method: 'createCalendar',
parameters: {
accountId: this.accountId,
calendar: {
calendarId: "",
name: "My Events"
}
},
onSuccess: this.createEvent.bind(this),
onFailure: this.failureHandler.bind(this)
});
};
This example demonstrates the creation of an event on the calendar created above:
CalendarAssistant.prototype.createEvent = function(response) {
if (response) {
Mojo.Log.info("Calendar Create ", Object.toJSON(response));
this.calendarId = response.calendarId;
}
this.currentMethod = "Event - Create";
var currentTime = new Date();
var startTime = currentTime.getTime();
this.controller.serviceRequest('palm://com.palm.calendar/crud', {
method: 'createEvent',
parameters: {
calendarId: this.calendarId,
event: {
calendarId: this.calendarId,
subject: "Forecast",
startTimestamp: startTime,
endTimestamp: startTime + 3600000,
allDay: false,
note: "Cliff Notes",
location: "Bluff",
attendees: [],
alarm: "none"
}
},
onSuccess: this.successEvent.bind(this),
onFailure: this.failureHandler.bind(this)
});
};
This example launches the Email application in the compose view with a subject (summary) and body (text):
this.controller.serviceRequest('palm://com.palm.applicationManager', {
method: 'launch',
parameters: {
id: 'com.palm.app.email',
params: {
summary: 'Check out this News story...',
text: this.storyFeed.stories[this.storyIndex].url
}
}
});
This example demonstrates launching the messaging app with a message already populated. All the user has to do is select a receipient:
this.controller.serviceRequest('palm://com.palm.applicationManager', {
method: 'launch',
parameters: {
id: 'com.palm.app.messaging',
params: {
messageText: "Check out: "+this.storyFeed.stori
es[this.storyIndex].url
}
}
});
You can also pass a recipient in as part of the email or messaging calls. Palm has not yet revealed the parameter for this functionality.







Thursday, 11 February 2010
this.controller.serviceRequest('palm://com.palm.applicationManager', {
method: 'launch',
parameters: {
id: 'com.palm.app.email',
params: {
summary: 'Check out this News story...',
text: this.storyFeed.stories[this.storyIndex].url
}
}
});
Thanks
David
Tuesday, 25 May 2010
Do you have any download-able sample codes for making calendar on palm pre. thanks!
how can i get a requires Synergy Account ID?
thanks
francis
Friday, 04 June 2010
How do I register new command or resource types?
Thanks!
Jinwoo