I have started a service and elevated it to foreground status, which seems to work. However now I want that service to start another service running in the background of another (unstarted) app, but it doesn't work:
2023-09-14 15:21:20.427 15578-15578/se.company.myservice E/DataExportService: Not allowed to start service Intent { dat=content://se.company.storageconnector.StorageConnector/cloud/ cmp=se.othercompany.a.b.c/se.company.x.service.InformationExportService }: app is in background uid UidRecord{72c502b u10a125 CAC bg:+3m48s37ms idle change:idle procs:0 seq(0,0,0)}
However if I click around and start the app containing the service I want to have started, then it starts to work. What is going on? I thought a foreground service was always allowed to start a background service?
I suspect that this is a security feature of Android, whereby stopped packages aren't allowed to be started (even from the foreground) unless started manually at least one time. The issue occurs after force stop (and probably fresh install), but after opening once, even rebooting doesn't stop it from working.
In Android the platform can start stopped packages by setting a flag in the start-intent, but non-platform apps aren't allowed to do this. I guess there is nothing I can do about it.