Android Question Foreground service

LucaMs

Expert
Licensed User
Longtime User
For various reasons, I started "playing" with Foreground Services, to try to keep an app / service always alive.

From what I understand, it is necessary to use a notification, whose icon appears at the top LEFT (notification that also emits a beep).

The basic project seems to work (maybe I will post it, also hoping that Erel will take a look at it and comment on it), but...

In my smartphone I have a pre-installed app, to set alarms, which I would call events. If one of these events is active, on the smartphone at the top RIGHT an alarm icon appears (no beeps) which is not a notification.

Can we do the same?
 

Alessandro71

Well-Known Member
Licensed User
Longtime User
If I understand correctly, you would like a notification with no beep/vibration cue.
This is what I use for my app

B4X:
    Dim n As Notification
    n.Initialize2(n.IMPORTANCE_LOW)
    n.Icon = "logo"
    n.Sound = False
    n.Vibrate = False
    n.Light = False
    n.OnGoingEvent = True
    n.SetInfo2(Application.LabelName, "App is running...", "startedfromnotification", Main)
    Service.StartForeground(99, n)
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Thanks, Alessandro, but that's not what I meant.

Referring to that pre-installed "Alarm Clock" app, on the system bar that is not a notification and doesn't behave like one, yet the app remains active in the background without the OS deleting it (it's a system icon, in fact it's on the right).

It is possible that only manufacturers can develop such apps, have special rights, access to special APIs.

"Luckily" I have another more complicated question to ask 😁 (new thread).
 
Last edited:
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
Referring to that pre-installed "Alarm Clock" app, on the system bar that is not a notification and doesn't behave like one, yet the app remains active in the background without the OS deleting it (it's a system icon, in fact it's on the right).

It is possible that only manufacturers can develop such apps, have special rights, access to special APIs.
I observed that (at least on my Samsung) the clock app opens a notification on some use cases (countdown timer for example).
Maybe the "alarm" function uses something like a "StartAt" receiver, that doesn't need a notification
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I observed that (at least on my Samsung) the clock app opens a notification on some use cases (countdown timer for example).
Maybe the "alarm" function uses something like a "StartAt" receiver, that doesn't need a notification
In my case, the "Alarm Clock" icon does not react to touch, does not do anything.


"Luckily" I have another more complicated question to ask 😁 (new thread).
https://www.b4x.com/android/forum/threads/jobscheduler.163783/
😊 :confused:
 
Upvote 0
Top