在主屏幕上创建通知

发布于 2024-11-29 03:33:45 字数 78 浏览 1 评论 0原文

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

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??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南城旧梦 2024-12-06 03:33:45

使用以下代码:

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

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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文