Commit 7df31d66 authored by Sébastien Toque's avatar Sébastien Toque
Browse files

init service in onCreate instead of onStart, because onStart can be called...

init service in onCreate instead of onStart, because onStart can be called several times during the service lifecycle
parent 48749e6c
......@@ -69,8 +69,8 @@ public class AudioService extends Service {
private boolean mDetectHeadset = true;
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
public void onCreate() {
super.onCreate();
// Get libVLC instance
try {
......@@ -83,17 +83,7 @@ public class AudioService extends Service {
mMediaList = new ArrayList<Media>();
mPrevious = new Stack<Media>();
mEventManager = EventManager.getIntance();
updateWidget(this);
}
@Override
public IBinder onBind(Intent intent) {
return mInterface;
}
@Override
public void onCreate() {
super.onCreate();
IntentFilter filter = new IntentFilter();
filter.addAction(VLCAppWidgetProvider.ACTION_WIDGET_BACKWARD);
filter.addAction(VLCAppWidgetProvider.ACTION_WIDGET_PLAY);
......@@ -104,12 +94,23 @@ public class AudioService extends Service {
registerReceiver(serviceReciever, filter);
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
updateWidget(this);
}
@Override
public void onDestroy() {
unregisterReceiver(serviceReciever);
super.onDestroy();
}
@Override
public IBinder onBind(Intent intent) {
return mInterface;
}
private BroadcastReceiver serviceReciever = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment