B4A Question Where has StartForeground gone? - Arf (first post)    Nov 20, 2017   (1 reaction) I think I got it.
Service.StartForeground is a command that can be used from inside Service_Create, to make that service be a foreground service.
You cannot Start a service as a foreground service from another module. Except maybe from within a different Service Module. B4A Question Capturing USB_DEVICE_ATTACHED and USB_DEVICE_DETACHED event - Erel (first post)    Nov 30, 2022 Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{c09bed7 u0
This happens because you disabled the automatic foreground mode. You need to call Service.StartForeground yourself, in Service_Start. B4A Example Service.StartForeground API 24+ - Jmu5667    Jan 24, 2017   (1 reaction) Hello All.
Just thought I would share some info with you. Most of our services in our apps would use
Service.StartForeground(1,main_service.n1)
in the service create sub, where main_service is a long running background task, and has the notification object in it. This was used so android would n B4A Question android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord - DonManfred (first post)    Apr 28, 2022   (1 reaction) you need to have the drawoverotherapps permission when you want to start a service while in background.
Did you add it?
Not sure if this is needed here: you are giving not enough informations. B4A Question Service.StartForeground(1, Notif1) under Android 13 - Erel (first post)    Jul 05, 2023 Please post the full stack trace from the logs. B4A Question Service.StartForeground with no notification icon - aaronk (first post)    Feb 11, 2018   (2 reactions) Worked it out. (I was over looking it)
In case someone else has the same issue..
removed:
Dim n As Notification
n.Initialize
n.Icon = "icon"
n.Vibrate = False
n.Sound = False
n.Light = False
n.SetInfo("Downloading file...", "", Target)
Service.StartForeground(1,n) B4A Question StartServiceAt("", DateTime.Now + 60 * 1000, True) - Erel (first post)    Nov 24, 2017   (1 reaction) Also call Service.StartForeground. B4A Question Service.StartForeground - DonManfred (first post)    Apr 15, 2019   (1 reaction) A working example: https://www.b4x.-location-tracking.99873/ B4A Question Starter Service Crashing - drgottjr (first post)    Oct 03, 2024   (1 reaction) many thanks to @agraham for raising an interesting point.
in spite of its name, StartForeground() doesn't start a foreground service. StartForegroundService() does.
StartForeground() moves a running service from background to foreground to post its notification.
StartForeground() is currently o B4A Question Service.startForeground shows "touch for more information or to stop the..." - Azam Memon (first post)    Oct 08, 2016 I want my service to stay running in background and don't get killed. Page: 1   2   3   4   5   6   7   Powered by ColBERT |