How to run a service in background on Android 10? Rooted device

43 views Asked by At

I have a rooted Android 10 and a service. It records the mic and accesses GPS coordinates. I'm trying to launch and run it in background, with no additional notifications in the Notification tray. And without any activity, icon, anything visual form.

I'll use ADB to launch it.

I've found out that there's no way anymore to run it in background initially - it has to be run in foreground first. But it then can be shifted to background and continue there with no notifications at all.

Is this correct?

If so, is it done by 2 consequetive calls:

val serviceAdditionaPermissions = FOREGROUND_SERVICE_TYPE_LOCATION or FOREGROUND_SERVICE_TYPE_MICROPHONE

startForeground(NOTIFICATION_ID, createNotification(), serviceAdditionaPermissions)
stopForeground(AccessibilityService.STOP_FOREGROUND_DETACH)

And it'll continue in background? With no notifications.

It'll be ok for me to run it first, for 1 minute, in foreground, as long as it then gets shifted into background.

Also, can root be leveraged here to overcome these restrictions?

0

There are 0 answers