#Constant Android Foreground Service

13 messages · Page 1 of 1 (latest)

sinful nacelle
#

I am currently working on an app for privte use which tracks an api for me.

I want that api to be checked every 20 / 60 seconds based on wifi or mobile data,

The Issue with this is that theres ForegroundService Timeouts that so far I havent found a way to bypass.

The app can ask for any permissions that are possible. I dont have to worry about things like it not being uploadable to playstore etc.

I currently try to start them with

var fgType = ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC | ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE | ServiceInfo.FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED
startForeground(NOTIF_ID, notification, fgType)

I have the manifest permissions for exact alarm for both use and schedule.

drowsy fractalBOT
#

This post has been reserved for your question.

Hey @sinful nacelle! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

sinful nacelle
#

bump

hallow vale
#

there is one option to do something every 15min (but the lowest is 15min)

#

and I think foreground services are an option if it's a long-running task

#

other than that: no, you can't really do it

#

alternatively, you might be able to use the notification service or something like that to have something that sends an information to the phones and not the phone polling

#

basically, you shouldn't constantly do polling

#

These are intentional restrictions

#

Android doesn't allow "run something all the time"

drowsy fractalBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

sinful nacelle
#

I have been running a change that seems to work.

Right now I'm using special use and system exempted without data sync and it seems to work so far.