@Override public void onUpdate(DownloadTask task) throws RemoteException { if (task == null) { return; } if (task != null) { long currentTime = System.currentTimeMillis(); if (mStartDonwload == 0) { mStartDonwload = currentTime; mAlreadyDownloadSize = task.getAlreadyDownloadSize(); } if (currentTime - mPrevRefreshTime > REFRESH_INTERVAL) { mPrevRefreshTime = currentTime; if (mShowNotification && mNotificationManager != null && mNotification != null) { // 更新通知栏的step为1% if (task.getAlreadyDownloadPercent() < mPercentCount && mPercentCount > 100) { return; } sendBroadcastingToAppCenter(task); mPercentCount += mStep; mDisplayPercent = task.getAlreadyDownloadPercent(); mNotification.flags = Notification.FLAG_ONGOING_EVENT; mNotification.contentIntent = mPendingIntent; mNotification.setLatestEventInfo( mContext, mDownloadText, mProgressText + " " + task.getAlreadyDownloadPercent() + "%", mPendingIntent); // mNotificationManager.notify(NOTIFY_TAG, (int) task.getId(), mNotification); if (mNotification.contentView != null) { mNotificationManager.notify(NOTIFY_TAG, (int) task.getId(), mNotification); } } } } }