浏览代码

Merge pull request #6721 from grote/6719-npe-onTransferProgress

Prevent NPE: Ensure that mNotificationManager is not null
Tobias Kaminsky 4 年之前
父节点
当前提交
ee075f285c
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      src/main/java/com/owncloud/android/files/services/FileUploader.java

+ 3 - 0
src/main/java/com/owncloud/android/files/services/FileUploader.java

@@ -715,6 +715,9 @@ public class FileUploader extends Service
             String fileName = filePath.substring(filePath.lastIndexOf(FileUtils.PATH_SEPARATOR) + 1);
             String text = String.format(getString(R.string.uploader_upload_in_progress_content), percent, fileName);
             mNotificationBuilder.setContentText(text);
+            if (mNotificationManager == null) {
+                mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+            }
             mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotificationBuilder.build());
         }
         mLastPercent = percent;