0
我想將多個進度通知合併到一個通知中。 Android的下載管理器究竟如何做到這一點。如果您從Chrome下載多個文件,則在下載時顯示爲一個通知。我該怎麼做呢?我有我的代碼在下面,但它顯示每個下載作爲一個單獨的通知。如何結合進度通知
主要
mNotifyManager = (NotificationManager) mActivity.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) createNotificationChannel();
mBuilder = new NotificationCompat.Builder(mActivity, "FileUpload")
.setSmallIcon(android.R.drawable.stat_sys_upload)
.setColor(ContextCompat.getColor(mActivity, R.color.colorNotification))
.setContentTitle(new File(mFilePath).getName())
.setContentText(mActivity.getResources().getString(R.string.app_name))
.setGroup(NOTIFICATION_GROUP)
.setProgress(0, 0, true);
mNotifyManager.notify(2312, mBuilder.build());
OnProgress
@Override
public void onProgress(String filePath, double progress, long uploadedBytes, long totalBytes) {
mBuilder.setProgress(100, (int) (progress * 100), false);
mNotifyManager.notify(2312, mBuilder.build());
}
這不會添加到像DownloadManager這樣的通知。這隻會使新的下載取代原來的。 –
更新了答案。 –
我已經在那裏有組,你可以在我的代碼中看到 –