Преглед изворни кода

proper reinitialize of service

Bartek Przybylski пре 12 година
родитељ
комит
b2a260286e
1 измењених фајлова са 7 додато и 0 уклоњено
  1. 7 0
      src/com/owncloud/android/files/services/FileObserverService.java

+ 7 - 0
src/com/owncloud/android/files/services/FileObserverService.java

@@ -48,6 +48,13 @@ public class FileObserverService extends Service {
 
     @Override
     public int onStartCommand(Intent intent, int flags, int startId) {
+        // this occurs when system tries to restart
+        // service, so we need to reinitialize observers
+        if (intent == null) {
+            initializeObservedList();
+            return Service.START_STICKY;
+        }
+            
         if (!intent.hasExtra(KEY_FILE_CMD)) {
             Log.e(TAG, "No KEY_FILE_CMD argument given");
             return Service.START_STICKY;