1

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

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

2 回答 2

1

这是一个可以帮助您的示例:http: //developer.android.com/training/notify-user/display-progress.html

于 2013-04-26T09:12:42.960 回答