foreground-service

Foreground Service killed on Huawei (GRA-UL00) - Protected Apps Enabled

亡梦爱人 提交于 2019-12-09 09:38:58
问题 My foreground sticky service is killed after a few hours without being restarted. I know this has been asked a couple of times, and I have read and verified all the checks on my device. Its important to note that this seems to occur only on Huawei devices. So allow me to provide the following details. Periodic Service public class PeriodicService extends Service { @Override public void onCreate() { super.onCreate(); acquireWakeLock(); foregroundify(); } private void foregroundify() { //

How to properly stop a foreground service?

穿精又带淫゛_ 提交于 2019-12-08 04:03:30
问题 I use startForeground to make my service "persist" in background and not be killed by the OS. I remove the service in the main activity onDestroy method by calling stopForeground and stopService. The problem is, when I swipe my app off the recent apps to kill it, the debug session is still running, whereas in the "normal" functioning (without using startForeground), the debug session terminates correctly. Using adb shell confirms that the app is still running. startForeground somehow creates

startForegroundService() is throwing IllegalStateException in Oreo on app BOOT_COMPLETED

对着背影说爱祢 提交于 2019-12-08 03:59:59
问题 The application I am having (in Android O) will start a service after device reboot. Once the device is rebooted, in the onReceive() method of the broadcast receiver it is calling the service as startForegroundService() for Android OS 8 and above. if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { context.startForegroundService(intent); } else { context.startService(intent); } Inside the service class it is starting the notification from the onStartCommand() method. But still it is throwing

Does service.startForeground imply wakelock?

随声附和 提交于 2019-12-07 15:55:31
问题 Question I am wondering if we need to aquire the WakeLock or if the service.startForeground() command does that anyway for us? I didn't find anything in the documentation. Goal We want to remove unnesessary stuff which might slow down the service start as we want to start capturing the sensor data as soon as possible and as the service might be restarted frequently. Context We're developing an Android library to capture sensor data with ~ 200 Hz for up to a couple of hours (research

Unable to Restart Service after killed despite running in foreground and with START_STICKY

送分小仙女□ 提交于 2019-12-07 14:20:14
问题 I am facing a critical issue with binded service running as foreground and with notification. I am doing everything correct as mentioned by most of the tutorials and solutions I found. I have an activity which starts a service and then bind with it. In onCreate() of service, i am using startForeground() and showing notification as well. I am also returning START_STICKY in onStartCommand() but when my application gets killed i see this in my log cat .. Force stopping package com.example

startForegroundService() is throwing IllegalStateException in Oreo on app BOOT_COMPLETED

笑着哭i 提交于 2019-12-06 16:48:43
The application I am having (in Android O) will start a service after device reboot. Once the device is rebooted, in the onReceive() method of the broadcast receiver it is calling the service as startForegroundService() for Android OS 8 and above. if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { context.startForegroundService(intent); } else { context.startService(intent); } Inside the service class it is starting the notification from the onStartCommand() method. But still it is throwing the IllegalStateException. Did someone faced similar issues in Android OS 8 and above? You have to

Foreground notification service not working in one plus devices

*爱你&永不变心* 提交于 2019-12-06 09:26:23
Below is the code for starting the foreground service. It is working fine for many devices like Samsung, moto, Vivo, Oppo and also with Android version nougat and oreo, but not working on One plus devices. Can anyone let me know if any extra changes or permission is required to run in One plus device or if any emulator supports one plus phones. public class ForegroundService extends Service { private Context ctx; private static final String PRIMARY_NOTIF_CHANNEL = "default"; @Override public void onCreate() { super.onCreate(); ctx = this; createNotificationService(); } private void

Oreo Background Services

不打扰是莪最后的温柔 提交于 2019-12-06 08:06:16
Within our application we use multiple Services and Intent Services for BLE communication, microphone recording, etc. We have noticed the newly Background Limitations and Restrictions (Yes, we did notice it rather late, I know). I've changed the implementations for using ContextCompat.startForegroundService() function and using the startForeground() with a notification like it stated in the docs. But we saw that when the application is killed , the Foreground Service dies also after a few minutes. Should it happen? Should the Foreground Service will only continue to work if the app is in the

Foreground service stops while running a long task

白昼怎懂夜的黑 提交于 2019-12-06 07:56:50
问题 I have a foreground service that should execute a long-running (~20 minutes) task in a single go (a file transfer using Bluetooth). However, the service gets stopped after a while. As a simple test app that reproduces the issue, I did the following, first the activity: public class MainActivity extends AppCompatActivity { private ServiceConnection connection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { TestService serv = (

Unable to Restart Service after killed despite running in foreground and with START_STICKY

☆樱花仙子☆ 提交于 2019-12-06 02:05:26
I am facing a critical issue with binded service running as foreground and with notification. I am doing everything correct as mentioned by most of the tutorials and solutions I found. I have an activity which starts a service and then bind with it. In onCreate() of service, i am using startForeground() and showing notification as well. I am also returning START_STICKY in onStartCommand() but when my application gets killed i see this in my log cat .. Force stopping package com.example.voicerecognizersp appid=10102 user=0 I/ActivityManager( 929): Killing proc 27176:com.example