foreground-service

Does service.startForeground imply wakelock?

只愿长相守 提交于 2019-12-05 21:13:20
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 environment). Right now we aquire a WakeLock and start the capturing service as ForegroundService to make sure

Foreground service stops while running a long task

大兔子大兔子 提交于 2019-12-04 12:37:56
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 = ((TestService.TestServiceBinder) service).getService(); serv.startLongProcess(); } @Override public void

Android 8 Foreground Service with Notification Channel

梦想与她 提交于 2019-12-04 09:45:29
I want to start a foreground service in Android 8 and I want to know how are foreground services compatible with the notification channel system. Let's say we start a foreground service, then we immediately create the required notification and assign it to a notification channel. Suddenly, the user decides to go into System Settings and disable the notification channel. What happens in this case? Will the service become a background service? Does it get killed? I haven't found a documented answer. Default notification settings: Foreground service notification: Disable notifications: Android 8

A foreground service gets killed and notification gets removed when app is swiped from recent apps

痴心易碎 提交于 2019-12-04 06:35:06
I have a foreground-service with notification. When the app is swiped away from recent apps tray, service gets killed and notification also gets removed. Here is the code for my service VoiceService.class : @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { showNotification(); Toast.makeText(this, "Service Started!", Toast.LENGTH_SHORT).show(); return START_STICKY; } private void showNotification() { new SetupTask(this).execute(); // a method in my code which works fine. Intent notificationIntent = new

Android InstantApp: Foreground service

瘦欲@ 提交于 2019-12-03 21:08:21
Unable to use foreground service inside InstantApp feature module. Getting below runtime security exception. java.lang.RuntimeException: Unable to start activity ComponentInfo{ . .XYZActivity}: java.lang.SecurityException: Method class android.app.ActivityManagerProxy.getServices not available to instant apps Android document says, Restricted features: Run on the device without users being aware. Foreground services are available. Instant apps can only be started through activities that support App Links, so services, content providers or broadcast receivers won't be able to start your app.

startForegroundService() did not call startForeground(), but it did

旧巷老猫 提交于 2019-12-03 13:00:20
I'm having the Context.startForegroundService() did not then call Service.startForeground() in my Android service, but I cannot figure out why it is happening. My application is for media streaming, and this error only occurs when you pause from the foreground notification (turning it into a regular notification), and you then swipe the notification away, which is intended to stop my service. Here is the only method where the startForegroundService , startForeground and stopForeground methods are called: private void configureServiceState(long action) { if (action == PlaybackStateCompat.ACTION

Oreo - Foreground service does not show foreground notification

蓝咒 提交于 2019-12-03 04:14:52
问题 So far, I've adjsuted my code to use ContextCompat.startForegroundService(context, intentService); to start my service. This way, it works on android < 26 and on android 26 (Oreo) as well. I still see a difference, in android oreo I don't see my custom foreground notification (I only see the "app is running in the background" notification). Do I have to adjust anything there as well? My service looks like this: public class BaseOverlayService extends Service { @Override public void onCreate()

Android doze mode and foreground service

蹲街弑〆低调 提交于 2019-12-02 20:36:58
问题 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

Sticky foreground service fails to restart with a “process is bad” error

耗尽温柔 提交于 2019-12-02 18:49:31
I have a started foreground service. I've taken care to return START_STICKY from onStartCommand . I've observed that foreground services don't run indefinitely but are periodically terminated by an Android internal module called the RestartProcessManager . Essentially a process LRU is maintained and the newly terminated service gets scheduled again if it's configured to do so(sticky or not). The issue I'm facing is with how the restart is being handled. Logcat indicates the service intent was being delivered, but failed because the "process is bad" After scouring through other sources I was

Oreo - Foreground service does not show foreground notification

非 Y 不嫁゛ 提交于 2019-12-02 17:33:56
So far, I've adjsuted my code to use ContextCompat.startForegroundService(context, intentService); to start my service. This way, it works on android < 26 and on android 26 (Oreo) as well. I still see a difference, in android oreo I don't see my custom foreground notification (I only see the "app is running in the background" notification). Do I have to adjust anything there as well? My service looks like this: public class BaseOverlayService extends Service { @Override public void onCreate() { super.onCreate(); moveToForeground(); } private void moveToForeground() { Notification notification