java - 通知错误 "The method setProgress(int, int, boolean) is undefined for the type NotificationCompat.Builder"

标签 java android

<分区>

有谁知道如何在下载文件时在通知栏中显示进度条更新?

    Context context = MyClass.this.getApplicationContext();
    NotificationManager notificationManager = (NotificationManager) 
                                context.getSystemService(NOTIFICATION_SERVICE);
    Notification updateComplete = new Notification();
    updateComplete.icon         = R.drawable.ic_launcher;
    updateComplete.tickerText   = "Starting to download...";
    updateComplete.when         = System.currentTimeMillis();
    Intent notificationIntent   = new Intent(context, MyClass.class);
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
                                                        notificationIntent, 0);
    String contentTitle         = "Download"; 
    updateComplete.setLatestEventInfo
                      (context, contentTitle, "downloading...", contentIntent);
    notificationManager.notify("yyy",1, updateComplete);

最佳答案

关于java - 通知错误 "The method setProgress(int, int, boolean) is undefined for the type NotificationCompat.Builder",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16232453/

相关文章:

java - 将多个 ObservableList 合并为一个 List

Java动态获取设置方法

java - 点运算符 `.`(在通用参数之前)是什么意思?

Java:如何具体 "forEach"操作类型

java - Android 数据库应用程序在“运行到电话”中崩溃

java - 当我使用 quarkus-resteasy-reactive-jackson 时,quarkus-resteasy-mutiny 扩展不存在警告

java - Axis2 Web 服务 - 版本控制

Android action.MAIN 和 category.LAUNCHER 函数

android - 在选项卡式 Activity 中将 sqlite 数据库中的所有数据显示到 ListView 中

java - 如何从网上下载图片并在运行时多次设置为背景?