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



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

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

下面是一个示例:http://developer.android.com/training/notify-user/display-progress.html

你可以在我的项目中引用我的工具:通知处理程序:https://code.google.com/p/wifi-scanner/source/browse/src/com/shixunaoyou/wifiscanner/update/DownloadNotificationHandler.java

和下载服务:https://code.google.com/p/wifi-scanner/source/browse/src/com/shixunaoyou/wifiscanner/update/DownloadUpdateService.java

最新更新