foreground-service

Android doze mode and foreground service

蹲街弑〆低调 提交于 2019-12-02 07:34:25
I read many questions here about doze mode like Android doze mode , Android N Doze mode - how to keep background download and processing? , Wakelock and doze mode and many others. But in many replies, opinions is different. I can't test it by myself (emulator does not support my processor, and my only test device is android 5.1). I would like to know the next situation. I have an activity, which controls the media player. On devices with android 6.0 and higher it wouldn't work as expected cause of doze mode. As many solutions says to prevent doze mode it should start a service in separate

A notification of the foreground service doesn't show on Android 8.+

家住魔仙堡 提交于 2019-12-02 05:57:28
My foreground service doesn't show a notification when it works on Android Oreo. It works perfectly on Android versions from 15 to 25. When I do targetSdkVersion from 26 to 25 this issue disappears. But this solution seems not good. I prepared test project with this issue. What should I do for fixing it on Android Oreo with targetSdkVersion 26 ? My foreground service, SoundService.java( full source ): public class SoundService extends Service implements MediaPlayer.OnErrorListener, MediaPlayer.OnPreparedListener, MediaPlayer.OnBufferingUpdateListener { private final static String TAG =

how to run GcmListenerService in foreground

假如想象 提交于 2019-12-01 16:12:39
I have a problem sometimes with my GCM service which is closed when RAM of my smartphone is automatically cleared (read this if you need more details). As far as I understand if I set my service to run in foreground it should help the system to to delete it with RAM. The method of Service.class onStartCommand() is usually used to run startForeground() method. But with the latest version of GCM implementation it is impossible since the onStartCommand() method of the parent GCMListenerService.class is defined as final and I cannot override it. So how can I set my gcm receiver to rum in

how to run GcmListenerService in foreground

岁酱吖の 提交于 2019-12-01 15:06:03
问题 I have a problem sometimes with my GCM service which is closed when RAM of my smartphone is automatically cleared (read this if you need more details). As far as I understand if I set my service to run in foreground it should help the system to to delete it with RAM. The method of Service.class onStartCommand() is usually used to run startForeground() method. But with the latest version of GCM implementation it is impossible since the onStartCommand() method of the parent GCMListenerService

Context.startForegroundService() did not then call Service.startForeground

非 Y 不嫁゛ 提交于 2019-12-01 07:00:33
My app will call startForegroundService(intent) in the onCreate of the MainActivity . And I put startForeground(ON_SERVICE_CONNECTION_NID, notification) in both the onCreate and the startCommand of the Service . But I'm still receiving this error occasionally. Exception android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground() android.app.ActivityThread$H.handleMessage (ActivityThread.java:1775) android.os.Handler.dispatchMessage (Handler.java:105) android.os.Looper.loop (Looper.java:164) android.app.ActivityThread.main (ActivityThread

StartForeground for IntentService

不羁岁月 提交于 2019-11-30 13:58:22
问题 I have an IntentService and I want to make it sticky with an ongoing notification. The problem is that the notification appears and then disappears immediately. The service continues to run. How should I use startForeground() in an IntentService ? @Override public int onStartCommand(Intent intent, int flags, int startId) { super.onStartCommand(intent, flags, startId); Notification notification = new Notification(R.drawable.marker, "Notification service is running", System.currentTimeMillis())

What is the proper way to stop a service running as foreground

帅比萌擦擦* 提交于 2019-11-28 08:56:05
I am trying to stop a service which is running as foreground service. The current issue is that when I call stopService() the notification still stays. So in my solution I have added a receiver which I am registering to inside the onCreate() Inside the onReceive() method I call stopforeground(true) and it hides the notification. And then stopself() to stop the service. Inside the onDestroy() I unregistered the receiver. Is there a more proper way to handle this? because stopService() simply doesn't work. @Override public void onDestroy(){ unregisterReceiver(receiver); super.onDestroy(); } Ilya

Android 9 (Pie), Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord

旧时模样 提交于 2019-11-27 16:11:31
问题 First of all, I looked at these; Context.startForegroundService() did not then call Service.startForeground() Context.startForegroundService() did not then call Service.startForeground Android 9 (Pie) Only: Context.startForegroundService() did not then call Service.startForeground() - Works fine on Oreo RemoteServiceException Context.startForegroundService() did not then call Service.startForeground() https://issuetracker.google.com/issues/76112072 I have a streaming application used by

What is the proper way to stop a service running as foreground

徘徊边缘 提交于 2019-11-26 20:31:59
问题 I am trying to stop a service which is running as foreground service. The current issue is that when I call stopService() the notification still stays. So in my solution I have added a receiver which I am registering to inside the onCreate() Inside the onReceive() method I call stopforeground(true) and it hides the notification. And then stopself() to stop the service. Inside the onDestroy() I unregistered the receiver. Is there a more proper way to handle this? because stopService() simply