Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java “通知错误”;类型NotificationCompat.Builder的方法setProgress(int,int,boolean)未定义;_Java_Android - Fatal编程技术网

Java “通知错误”;类型NotificationCompat.Builder的方法setProgress(int,int,boolean)未定义;

Java “通知错误”;类型NotificationCompat.Builder的方法setProgress(int,int,boolean)未定义;,java,android,Java,Android,有人知道在下载文件时如何在通知栏中显示进度条更新吗 Context context = MyClass.this.getApplicationContext(); NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE); Notificatio

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

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

这里有一个示例可以帮助您:

这里有一个示例可以帮助您:

您可以在我的项目中引用我的工具: 通知处理程序:

下载服务:

您可以在我的项目中引用我的工具: 通知处理程序:

下载服务:

我还原了,因为它无效。伙计们,如果你建议编辑,为什么要更改字符串?这毫无意义。更改个人格式设置也是浪费时间。我还原了,因为它无效。伙计们,如果你建议编辑,为什么要更改字符串?这毫无意义。更改个人格式设置也是浪费时间。谢谢!但是我在.setProgress中有一个错误,它说“类型NotificationCompat.Builder的方法setProgress(int,int,boolean)未定义”。对于mBuilder.build()“NotificationCompat.Builder类型的方法build()未定义”,这是您希望应用程序使用的android版本?还添加了支持库吗?谢谢!但是我在.setProgress中有一个错误,它说“类型NotificationCompat.Builder的方法setProgress(int,int,boolean)未定义”。对于mBuilder.build()“NotificationCompat.Builder类型的方法build()未定义”,这是您希望应用程序使用的android版本?您是否在支持库中添加了?