[Android] Move scan service instance init in onCreate()
Geoffrey Métais
git at videolan.org
Thu Apr 6 16:33:20 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Apr 6 16:10:20 2017 +0200| [27715ac8419c249e96d5eec12c97dd25e3406821] | committer: Geoffrey Métais
Move scan service instance init in onCreate()
> https://code.videolan.org/videolan/vlc-android/commit/27715ac8419c249e96d5eec12c97dd25e3406821
---
.../src/org/videolan/vlc/MediaParsingService.java | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.java b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
index 8955755..a1c6300 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.java
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
@@ -79,8 +79,15 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
@Override
public void onCreate() {
super.onCreate();
+ mMedialibrary = VLCApplication.getMLInstance();
+ mMedialibrary.addDeviceDiscoveryCb(MediaParsingService.this);
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(ACTION_PAUSE_SCAN);
+ filter.addAction(ACTION_RESUME_SCAN);
+ registerReceiver(mReceiver, filter);
PowerManager pm = (PowerManager) VLCApplication.getAppContext().getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
+ mWakeLock.acquire();
}
@Nullable
@@ -91,12 +98,6 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
- mMedialibrary = VLCApplication.getMLInstance();
- IntentFilter filter = new IntentFilter();
- filter.addAction(ACTION_PAUSE_SCAN);
- filter.addAction(ACTION_RESUME_SCAN);
- registerReceiver(mReceiver, filter);
- mMedialibrary.addDeviceDiscoveryCb(MediaParsingService.this);
switch (intent.getAction()) {
case ACTION_INIT:
setupMedialibrary(intent.getBooleanExtra(StartActivity.EXTRA_UPGRADE, false));
@@ -110,11 +111,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
case ACTION_DISCOVER_DEVICE:
discoverStorage(intent.getStringExtra(EXTRA_PATH), intent.getStringExtra(EXTRA_UUID));
break;
- default:
- return START_NOT_STICKY;
}
- if (!mWakeLock.isHeld())
- mWakeLock.acquire();
return START_NOT_STICKY;
}
More information about the Android
mailing list