Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
...
Public notif As Notification
Private NotifIcon24 As Bitmap
Private NotifIcon256 As Bitmap
Private PlayIcon,PauseIcon,PrevIcon,NextIcon,ForwardIcon,RewindIcon As Bitmap
Public IconeNotifPlay As Boolean
...
End Sub
Sub Service_Create
...
' Lecture des icones notif
NotifIcon24 = LoadBitmap(File.DirAssets,"icon24.png")
NotifIcon256 = LoadBitmap(File.DirAssets,"icon256.png")
'PlayPauseIcon = LoadBitmap(File.DirAssets,"ico_playpause.png")
PlayIcon = LoadBitmap(File.DirAssets,"ico_play.png")
PauseIcon = LoadBitmap(File.DirAssets,"ico_pause.png")
PrevIcon = LoadBitmap(File.DirAssets,"ico_prev.png")
NextIcon = LoadBitmap(File.DirAssets,"ico_next.png")
ForwardIcon = LoadBitmap(File.DirAssets,"ico_forward.png")
RewindIcon = LoadBitmap(File.DirAssets,"ico_rewind.png")
ConstruitNotif
...
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER
...
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StartForeground(1,notif)
End Sub
public Sub ConstruitNotif
' Construction en fonction du contexte
Private n As NB6
Private LibNotif As String = ""
n.Initialize("default", Application.LabelName,"DEFAULT")
n.SmallIcon(NotifIcon24)
n.LargeIcon(NotifIcon256)
n.OldNotificationIcon("icon")
n.Visibility("PUBLIC")
n.SetDefaults(False,False,False)
n.OnlyAlertOnce(True)
n.DeleteAction(Notifs,"ActionDelete")
If Starter.Player.FichierActif Then
n.AddButtonAction(PrevIcon,"|<", Notifs,"ActionPrev")
n.AddButtonAction(RewindIcon,"<<", Notifs,"ActionRewind")
If Starter.Player.IsPlaying Then
n.AddButtonAction(PauseIcon,"||", Notifs,"ActionPlayPause")
IconeNotifPlay = False
Else
n.AddButtonAction(PlayIcon,"|>", Notifs,"ActionPlayPause")
IconeNotifPlay = True
End If
n.AddButtonAction(ForwardIcon,">>", Notifs,"ActionForward")
n.AddButtonAction(NextIcon,">|", Notifs,"ActionNext")
n.MediaStyle(5)
LibNotif = Starter.Player.NomFichier
Else
' Pas de lecture en cours
LibNotif = c.string_Main_LibNotif
End If
LibNotif = c.string_Main_LibNotif
notif = n.Build(LibNotif,"","tag",Main)
End Sub
' This sub is called many times to update notif bar accordinf to context
public Sub MajNotificationBar
' Construction en fonction du contexte
ConstruitNotif
' Affichage
notif.Notify(1)
End Sub