finish apllication after clicking Exit

This commit is contained in:
Milos Kozak 2018-07-31 19:11:32 +02:00
parent ce16dd747b
commit 9d686adf7e
6 changed files with 29 additions and 12 deletions

View file

@ -161,8 +161,6 @@ public class NSClientService extends Service {
destroy();
stopSelf();
if (L.isEnabled(L.NSCLIENT))
log.debug("EventAppExit finished");
}
@Subscribe

View file

@ -6,10 +6,21 @@ import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;
import com.squareup.otto.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.logging.L;
/**
* Keeps AndroidAPS in foreground state, so it won't be terminated by Android nor get restricted by the background execution limits
*/
public class DummyService extends Service {
private static Logger log = LoggerFactory.getLogger(L.CORE);
@Nullable
@Override
public IBinder onBind(Intent intent) {
@ -24,8 +35,24 @@ public class DummyService extends Service {
return START_STICKY;
}
@Subscribe
public void onStatusEvent(EventAppExit event) {
if (L.isEnabled(L.CORE))
log.debug("EventAppExit received");
stopSelf();
}
@Override
public void onCreate() {
MainApp.bus().register(this);
}
@Override
public void onDestroy() {
if (L.isEnabled(L.CORE))
log.debug("onDestroy");
MainApp.bus().unregister(this);
stopForeground(true);
}
}

View file

@ -412,8 +412,6 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
MainApp.instance().getApplicationContext().unregisterReceiver(receiver);
stopSelf();
if (L.isEnabled(L.PUMP))
log.debug("EventAppExit finished");
}
public PumpEnactResult setUserOptions() {

View file

@ -93,9 +93,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
MainApp.instance().getApplicationContext().unregisterReceiver(receiver);
stopSelf();
if (L.isEnabled(L.PUMP))
log.debug("EventAppExit finished");
}
}
@Subscribe
public void onStatusEvent(final EventPreferenceChange pch) {

View file

@ -526,8 +526,6 @@ public class DanaRSService extends Service {
log.debug("EventAppExit received");
stopSelf();
if (L.isEnabled(L.PUMP))
log.debug("EventAppExit finished");
}
void waitForWholeMinute() {

View file

@ -112,9 +112,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
MainApp.instance().getApplicationContext().unregisterReceiver(receiver);
stopSelf();
if (L.isEnabled(L.PUMP))
log.debug("EventAppExit finished");
}
}
@Subscribe
public void onStatusEvent(final EventPreferenceChange pch) {