public void createNotification(
String title, String fileName,
boolean setProgressBar,
int maxValue, int progress, int notificationId,
boolean firstTime) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
if (firstTime) {
builder.setContentText(fileName);
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setAutoCancel(false);
}
builder.setContentTitle(title);
if (setProgressBar) {
builder.setProgress(maxValue, progress, false);
}
Notification notification = builder.build();
NotificationManager notificationManager =
(NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(notificationId, notification);
}
다른 활동에서 알림을 만들고 다른 활동에서 업데이트하고 있습니다. 다음과 같이 업데이트합니다 :업데이트시 알림 표시 줄이 사라집니다.
notificationManager.createNotification(
"Downloading", document.getName(),
true,
(int) document.getContentLength(), (int)completedBytes,
(int) document.getContentLength(),
false);
나는 매우 새로운 기능입니다. 모든 단서가 도움이 될 것입니다. 감사.
수정 된 코드 형식; minor smithing – Prune