I have an application where the user is requested to sign in and then presented with an activity. A service is also started on sign in which uses the location manager to track his current location. everything works perfectly until the application is left in standby mode (screen off and app in background for more than ~ 1 hour)
how can I prevent this?
as I understand, if I have a foreground service running, the OS should not kill the app.. so what am I doing wrong? the OS I am testing on is Oreo
starting the service on sign in:
startService(intent);
the service:
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
return START_STICKY;
}
@Override
public void onCreate() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Notification notification = updateNotificationContent(); // the service notification
if (notification == null)
stopSelf();
startForeground(id, notification);
}
I added logging on destroy function of the activity and service to detect when this is happening buta log is never written when this behavior happens (ofcourse it enters in normal case when i destroy the app)
from Foreground app killed by OS after ~ 1 hour in standby mode
No comments:
Post a Comment