[Android] Delay storages check

Geoffrey Métais git at videolan.org
Wed Apr 4 10:32:54 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Apr  4 10:32:09 2018 +0200| [f32739cf57acaa968a86f74d0b89df3bc4c7221d] | committer: Geoffrey Métais

Delay storages check

Ensure app is foreground when we start service

> https://code.videolan.org/videolan/vlc-android/commit/f32739cf57acaa968a86f74d0b89df3bc4c7221d
---

 vlc-android/src/org/videolan/vlc/ExternalMonitor.java | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/ExternalMonitor.java b/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
index 90603164c..4b265de14 100644
--- a/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
+++ b/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
@@ -76,13 +76,17 @@ public class ExternalMonitor extends BroadcastReceiver {
         storageFilter.addDataScheme("file");
         ctx.registerReceiver(instance, networkFilter);
         ctx.registerReceiver(instance, storageFilter);
-        if (AndroidUtil.isICSOrLater)
-            checkNewStorages(ctx);
+        checkNewStorages(ctx);
     }
 
     private static void checkNewStorages(final Context ctx) {
-        if (VLCApplication.getMLInstance().isInitiated())
-            ctx.startService(new Intent(Constants.ACTION_CHECK_STORAGES, null,ctx, MediaParsingService.class));
+        if (AndroidUtil.isICSOrLater && VLCApplication.getMLInstance().isInitiated())
+            new Handler(Looper.getMainLooper()).post(new Runnable() {
+                @Override
+                public void run() {
+                    ctx.startService(new Intent(Constants.ACTION_CHECK_STORAGES, null,ctx, MediaParsingService.class));
+                }
+            });
     }
 
     static void unregister(Context ctx) {



More information about the Android mailing list