October 22, 2024
Chicago 12, Melborne City, USA
Android

Forever running Service for API 34+


I have been researching without results for some time now. A foreground service whose service is forever running needs to be created.
Idea can be found on this gist: https://gist.github.com/varunon9/f2beec0a743c96708eb0ef971a9ff9cd

Issues is that when starting a foreground service from a Worker or from onDestroy() lifecycle callback of the ForegroundService itself the following error would appear:

android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service com.example.myapp/com.example.myapp.proxy.service.MyForegroundService

Does someone have an idea on how to implement this properly?



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video