Android Question TimeOut Notification

AHilberink

Active Member
Licensed User
Longtime User
Hi,

I tried to change the TimeOut of a notification of the AutoCancel. I use code from:
https://www.b4x.com/android/forum/threads/nb6-class-additional-functions.104319/

and add to NB6:
B4X:
'Specifies a duration in milliseconds after which this notification should be canceled, if it is not already canceled.
'Used in SDK > 25 only
Public Sub TimeoutAfter(durationMs As Long) As NB6
 If IsChannel Then
  NotificationBuilder.RunMethod("setTimeoutAfter", Array(durationMs))
 End If
 Return Me
End Sub

My code:
B4X:
nb.TimeoutAfter(18000)

but it don't seems to work. Still AutoCancel after normal timeout.

Can it be done and how?

BR, André
 

AHilberink

Active Member
Licensed User
Longtime User
No. It should work.

I cannot get it to work. This is my complete Notify code:
B4X:
    Dim n As Notification

    If(Lamp And Trillen) Then
        nb.Initialize("chauffeurlt", Application.LabelName, "HIGH").AutoCancel(True).SmallIcon(Icon)
    Else If(Lamp) Then
        nb.Initialize("chauffeurl", Application.LabelName, "HIGH").AutoCancel(True).SmallIcon(Icon)
    Else If(Trillen) Then
        nb.Initialize("chauffeurt", Application.LabelName, "HIGH").AutoCancel(True).SmallIcon(Icon)
    Else
        nb.Initialize("chauffeur", Application.LabelName, "HIGH").AutoCancel(True).SmallIcon(Icon)
    End If
    nb.SetDefaults(False,Lamp,Trillen)
    nb.TimeoutAfter(18000)
    nb.AddButtonAction(Null, cs.Initialize.Color(Colors.Red).BackgroundColor(Colors.LightGray).Size(20).Bold.Append("Stop alarm").PopAll, StopAlarm, "Stop alarm")
    n=nb.Build("CIRIS Chauffeur", Body, "CIRIS Chauffeur", Beveiliging)
    n.Notify(2)

Could it had something to do with the n.Notify? It runs within a Service. Could this be the problem? Can I check something?

BR, André
 
Upvote 0
Top