在主屏幕上创建通知

时间:2011-08-09 08:47:42

标签: blackberry icons notifications background-process

我想在应用程序在后台运行时在主屏幕上创建通知图标,在应用程序中有线程用于检查即将到来的响应,而我想在主屏幕中显示使用通知图标,可以帮助我?

1 个答案:

答案 0 :(得分:2)

使用以下代码:

public static void registerIndicator() {
        EncodedImage mImageGreen = EncodedImage.getEncodedImageResource("res/mail.png");
        ApplicationIcon mIconGreen = new ApplicationIcon(mImageGreen);
        ApplicationIcon mIcon = mIconGreen;
        try {
            ApplicationIndicatorRegistry reg = ApplicationIndicatorRegistry.getInstance();
            ApplicationIndicator indicator = reg.register(mIcon, false, true);
        } catch (Exception ex) { }
    }

public static void updateIndicatorValue(int value) {

    try {
        ApplicationIndicatorRegistry reg = ApplicationIndicatorRegistry.getInstance(); 
        ApplicationIndicator appIndicator = reg.getApplicationIndicator(); 
        appIndicator.setValue(value); 
    } catch (Exception e) { }
}

public static int getIndicatorValue() {
    try {
        ApplicationIndicatorRegistry reg = ApplicationIndicatorRegistry.getInstance(); 
        ApplicationIndicator appIndicator = reg.getApplicationIndicator(); 
        return appIndicator.getValue(); 
    } catch (Exception e) { }
    return -1;
}