开发者

Blackberry ApplicationIndicator click handler on Home Screen

开发者 https://www.devze.com 2023-02-12 10:43 出处:网络
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 ic开发者_StackOverflow社区on is clicked.

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 ic开发者_StackOverflow社区on 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消