Android Question Notification Banner (Pinned) And Service

dennmtr

Member
Licensed User
I want to ensure that the notification banner will be always active and non dismiss able , only when the phone is with screen active, awake, and unlocked (SECRET). No background, not at sleep mode not with screen off, not with screen locked. Of course with the less resources and battery consume. Can i do it without service schedule?

B4X:
#Region  Service Attributes
    #StartAtBoot: True
    
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
End Sub

Sub Service_Create
    Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER
End Sub

Sub Service_Start (StartingIntent As Intent)
    
    If Helpers.GetDetails.GetDefault("quickaccess", True) = False Then
        Die
        Return
    End If
    
    Service.StartForeground(Constants.NOTIFICATION_QUICK_ACCESS, Helpers.QuickAccessNotification)
    
    StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, False)
    
End Sub

Sub Die
    CancelScheduledService(Me)
    StopService(Me)
End Sub

Sub Service_Destroy
End Sub

Thanks
 

dennmtr

Member
Licensed User
Yes.... My question is for the service schedule (which means the notification). If I stop scheduling the service what will be happen next time i wake up my phone after hours, will i see the notification or not?

The above code works as expected with StartServiceAt but i dont now how this affects the battery thats why i am asking.
There is no other background or foreground tasks, the only reason this service exists its for the non dismiss able banner with shorcut button actions
 
Upvote 0

dennmtr

Member
Licensed User
Thank you Erel it was so simple, i added the relative set method to NB6
 
Upvote 0
Top