stefanoa Active Member Licensed User Longtime User Jan 9, 2012 #1 Notification problem with Delete or AutoCancel Hi, i've create a service (AlarmService) with: Code: Copy '--------------------------------------------------------- Sub Process_Globals Dim AlarmID As Int Dim DescriptionTitle As String Dim DescriptionBody As String Dim DoneSuccessfully As Boolean Dim Notification1 As Notification End Sub Sub Service_Create Notification1.Initialize Notification1.Icon = "icon" 'use the application icon file for the notification Notification1.Vibrate = True Notification1.SetInfo(DescriptionTitle, DescriptionBody, "") ' Main) Notification1.Sound = True Notification1.AutoCancel =True End Sub Sub Service_Start (StartingIntent As Intent) Service.StartForeground(1, Notification1) End Sub '---------------------------------- notification is activated properly !! 1) Why clicking on the notification can not be erased automatically? (Notification1.AutoCancel =True) 2) if I try to manually delete it by ID, notification is NOT DELETED!!! in Main: Sub AlarmReset Dim noti As Notification noti.Cancel(1) ToastMessageShow(trans.GetText("ALARM CANCELED") & " (ID: " & tmpAlertID & ")", False) End Sub thanks Last edited by a moderator: Jan 9, 2012
Notification problem with Delete or AutoCancel Hi, i've create a service (AlarmService) with: Code: Copy '--------------------------------------------------------- Sub Process_Globals Dim AlarmID As Int Dim DescriptionTitle As String Dim DescriptionBody As String Dim DoneSuccessfully As Boolean Dim Notification1 As Notification End Sub Sub Service_Create Notification1.Initialize Notification1.Icon = "icon" 'use the application icon file for the notification Notification1.Vibrate = True Notification1.SetInfo(DescriptionTitle, DescriptionBody, "") ' Main) Notification1.Sound = True Notification1.AutoCancel =True End Sub Sub Service_Start (StartingIntent As Intent) Service.StartForeground(1, Notification1) End Sub '---------------------------------- notification is activated properly !! 1) Why clicking on the notification can not be erased automatically? (Notification1.AutoCancel =True) 2) if I try to manually delete it by ID, notification is NOT DELETED!!! in Main: Sub AlarmReset Dim noti As Notification noti.Cancel(1) ToastMessageShow(trans.GetText("ALARM CANCELED") & " (ID: " & tmpAlertID & ")", False) End Sub thanks
Erel B4X founder Staff member Licensed User Longtime User Jan 9, 2012 #2 Service.StartForeground adds an ongoing notification which cannot be removed until you call Service.StopForeground. Upvote 0
Service.StartForeground adds an ongoing notification which cannot be removed until you call Service.StopForeground.
stefanoa Active Member Licensed User Longtime User Jan 9, 2012 #3 you can give me an example of how to call Service.StopForeground ? or is there a better way to open a notification rather than Service.StartForeground ? i've to set an alarm (or notification) from a task.... thanks Upvote 0
you can give me an example of how to call Service.StopForeground ? or is there a better way to open a notification rather than Service.StartForeground ? i've to set an alarm (or notification) from a task.... thanks
Erel B4X founder Staff member Licensed User Longtime User Jan 9, 2012 #4 You can use Notification.Notify if you do not need to mark the service as a foreground service. Upvote 0
stefanoa Active Member Licensed User Longtime User Jan 9, 2012 #5 with Notification.Notify and a service, the single notification is ok. thanks Last edited: Jan 9, 2012 Upvote 0
hookshy Well-Known Member Licensed User Longtime User Jul 2, 2014 #6 I encountered the same problem and I still have small question is there a difference between 1 .nofification.nofify 2 .Service.StartForeground(1,notification) ?? I did not called startforeground but yet as I defined the notification to autocancel it won't work with nortification.cancel ! The solution remains to call CallSub(myservice,"off_front") where off_front will stop foreground state of the service. Please coment to clear things out about notification.cancel option ! Thanks Upvote 0
I encountered the same problem and I still have small question is there a difference between 1 .nofification.nofify 2 .Service.StartForeground(1,notification) ?? I did not called startforeground but yet as I defined the notification to autocancel it won't work with nortification.cancel ! The solution remains to call CallSub(myservice,"off_front") where off_front will stop foreground state of the service. Please coment to clear things out about notification.cancel option ! Thanks
hookshy Well-Known Member Licensed User Longtime User Jul 2, 2014 #7 this is from Erel's tutorial and it works just fine All parameters must be difined in the same place with the nofification.initialise statement nofification.notify can be triggered when needed. Code: Copy Sub Activity_Create(FirstTime As Boolean) Dim n1, n2 As Notification n1.Initialize n1.Icon = "icon" n1.SetInfo("n1", "n1", "") n2.Initialize n2.Icon = "icon" n2.SetInfo("n2", "n2", "") n1.Notify(1) n2.Notify(2) End Sub Upvote 0
this is from Erel's tutorial and it works just fine All parameters must be difined in the same place with the nofification.initialise statement nofification.notify can be triggered when needed. Code: Copy Sub Activity_Create(FirstTime As Boolean) Dim n1, n2 As Notification n1.Initialize n1.Icon = "icon" n1.SetInfo("n1", "n1", "") n2.Initialize n2.Icon = "icon" n2.SetInfo("n2", "n2", "") n1.Notify(1) n2.Notify(2) End Sub