vman
vman

Reputation: 65

Create Notifications On Home Screen

I want to create notification icon on home screen when the application is run in background,,in the application have thread for check upcoming respon,,and i want to show in home screen use notification icon,,can help me??

Upvotes: 1

Views: 454

Answers (1)

Farid Farhat
Farid Farhat

Reputation: 2310

Use the following code:

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;
}

Upvotes: 2

Related Questions