call startForeground()

This commit is contained in:
AdrianLxM 2019-06-30 15:38:04 +02:00 committed by GitHub
parent bdf0b0e07d
commit d42794137f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.services; package info.nightscout.androidaps.services;
import android.app.Notification;
import android.app.Service; import android.app.Service;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -16,6 +17,7 @@ import java.io.IOException;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin;
public class AlarmSoundService extends Service { public class AlarmSoundService extends Service {
private static Logger log = LoggerFactory.getLogger(L.CORE); private static Logger log = LoggerFactory.getLogger(L.CORE);
@ -28,8 +30,7 @@ public class AlarmSoundService extends Service {
@Override @Override
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service. return null;
throw new UnsupportedOperationException("Not yet implemented");
} }
@Override @Override
@ -40,6 +41,8 @@ public class AlarmSoundService extends Service {
} }
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
Notification notification = PersistentNotificationPlugin.getPlugin().updateNotification();
startForeground(PersistentNotificationPlugin.ONGOING_NOTIFICATION_ID, notification);
if (player != null && player.isPlaying()) if (player != null && player.isPlaying())
player.stop(); player.stop();
if (L.isEnabled(L.CORE)) if (L.isEnabled(L.CORE))