Prevent my Notification clearing

onumad

Member
Licensed User
Longtime User
See zip file, please :)

I have this Service
B4X:
'Service -llamando- module
Sub Process_Globals

End Sub
Sub Service_Create   
End Sub

Sub Service_Start
   CallSubDelayed(Main, "Nota_Servicio_Iniciado")
End Sub
and this Activity:
B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   'Iconos e imágenes
   Dim Nota As Notification
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
End Sub


Sub Activity_Create(FirstTime As Boolean)
   
   If FirstTime Then   ' Cargamos los Iconos a usar      
      If IsPaused(srv_llamada) Then StartService(srv_llamada)
   End If

End Sub

Sub Activity_Resume
   
End Sub

Sub Activity_Pause (UserClosed As Boolean)
   StopService(srv_llamada)
   Activity.Finish
   ExitApplication
End Sub


Sub Nota_Servicio_Iniciado
      Nota.Initialize
      Nota.OnGoingEvent=True
      Nota.AutoCancel = False
      Nota.Vibrate = False
      Nota.Sound = False
      Nota.Icon = "icon"
      Nota.SetInfo("My Note", "I don't want be cleared!","Main")      
      Nota.OnGoingEvent=False
      Dim r As Reflector
      r.Target = Nota
      r.SetField("tickerText", "My Note; Servicio iniciado", "java.lang.String")      
      Nota.Notify(1)   
End Sub

I need to do this note persistent; it will no cleared from Notifications list when you push "Clear" notifications.

Is possible this?

Thank you!

:
 

Attachments

  • Mynotedontwantcleared.zip
    19.6 KB · Views: 126

onumad

Member
Licensed User
Longtime User
Well. I tried
B4X:
r.SetPublicField("flags","FLAG_NO_CLEAR","java.lang.Object")
and
B4X:
r.SetPublicField("flags","FLAG_NO_CLEAR","java.lang.String")
but I haven't luck :(
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
With the default b4a notification object, the only real option you have is to set
B4X:
Nota.OnGoingEvent = True
Which you do in your code but then set it to false again further down.

Another option is to download and install the Advanced Notification Library which adds the NoClear function.

The difference between the 2 is that 'OnGoingEvent' shows the Notification in the On Going Event section. NoClear show in the standard list.

Hope this helps.
 
Upvote 0

onumad

Member
Licensed User
Longtime User
bartx, thank you;
B4X:
Nota.OnGoingEvent = True
was the answer.

I'm really impressed with B4A. In 11 days I have been able to create my first "serious" application. Now I have to make it nice and see how it is published in PlayStore
 
Upvote 0
Top