【问题标题】:Notification Error "The method setProgress(int, int, boolean) is undefined for the type NotificationCompat.Builder" [duplicate]通知错误“NotificationCompat.Builder 类型的方法 setProgress(int, int, boolean) 未定义” [重复]
【发布时间】:2013-04-26 08:57:32
【问题描述】:

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

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

【问题讨论】:

  • 我恢复了suggested edit,因为它无效。伙计们,如果您建议编辑,为什么要更改字符串?这是没有意义的。更改个人格式偏好也确实是在浪费时间。

标签: java android


【解决方案1】:

【讨论】:

  • 谢谢!但是我对 .setProgress 有一个错误,它说“对于 NotificationCompat.Builder 类型的方法 setProgress(int, int, boolean) 是未定义的”。并且还使用 mBuilder.build() “NotificationCompat.Builder 类型的方法 build() 未定义”
  • 您希望您的应用在哪个 android 版本上运行?支持库中也添加了吗?
【解决方案2】:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-05-25
  • 1970-01-01
  • 1970-01-01
  • 2014-05-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多