From 3ed95dbdfc06f585ebd720fb6fe20803f092698d Mon Sep 17 00:00:00 2001 From: seven332 Date: Sat, 27 Dec 2014 13:54:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E5=85=8D=E5=A4=9A=E6=AC=A1=E5=88=B7?= =?UTF-8?q?=E6=96=B0=20Notification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/hippo/ehviewer/service/DownloadService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/com/hippo/ehviewer/service/DownloadService.java b/src/com/hippo/ehviewer/service/DownloadService.java index 8da78b3f4..41f2e3ed2 100644 --- a/src/com/hippo/ehviewer/service/DownloadService.java +++ b/src/com/hippo/ehviewer/service/DownloadService.java @@ -364,6 +364,8 @@ public class DownloadService extends Service notifyUpdate(); } + private long mLastStartForegroundTime = 0; + @Override public void onDownload(int gid, int downloadSize, int totalSize) { if (mCurDownloadInfo == null) @@ -377,7 +379,12 @@ public class DownloadService extends Service mBuilder.setContentTitle(getString(R.string.downloading) + " " + gid) .setContentText(mSpeedStr) .setProgress(totalSize, downloadSize, false); - startForeground(DOWNLOADING_NOTIFY_ID, mBuilder.build()); + + long now = System.currentTimeMillis(); + if (now - mLastStartForegroundTime > 500) { + startForeground(DOWNLOADING_NOTIFY_ID, mBuilder.build()); + mLastStartForegroundTime = now; + } notifyUpdate(); }