问题
I am creating an application which has a notification icon on the status bar of the BlackBerry home screen. I want to launch my app when this notification icon is clicked.
I am able to create a notification icon in the status bar with ApplicationIndicator, but I am not able to register a click handler to launch the application.
回答1:
In Blackberry OS 6.0 we have a new API which can be used for launching an app from the notification bar. Here is an example:
try {
DemoMessage msg = new DemoMessage();
ApplicationDescriptor daemonDescr = ApplicationDescriptor.currentApplicationDescriptor();
ApplicationDescriptor mainDescr = new ApplicationDescriptor(daemonDescr, "MyAppName", new String[] {});
// Get existing messages from storage and register them in folders
ApplicationFolderIntegrationConfig inboxIntegration = new ApplicationFolderIntegrationConfig(true, true, mainDescr);
ApplicationMessageFolder folder = ApplicationMessageFolderRegistry.getInstance().registerFolder(
APPLICATION_ID, "MyApplictionFolderName", new ReadableListImpl(),inboxIntegration);
folder.fireElementAdded(msg);
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NullPointerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Where DemoMessage
and ReadableListimpl
are classes from Blackberry 6.0's MessageListDemo
sample app.
For reference, see also this related question: Opening application from notification bar in blackberry.
来源:https://stackoverflow.com/questions/5044527/blackberry-applicationindicator-click-handler-on-home-screen