#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
Private smiley As Bitmap
Private xui As XUI
Private OldIntent As Intent
End Sub
Sub Globals
Private CLV As CustomListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
smiley = LoadBitmapResize(File.DirAssets, "smiley.png", 24dip, 24dip, False)
End If
Activity.LoadLayout("1")
CLV.DefaultTextBackgroundColor = Colors.Black
CLV.AddTextItem("sound only", "Simple_Notification_Sound")
CLV.AddTextItem("Sound & Vib", "Simple_Notification_Sound_Vib")
CLV.AddTextItem("only vib", "Simple_Notification_Vib")
End Sub
Sub CLV_ItemClick (Index As Int, Value As Object)
CallSub(Me, Value)
End Sub
Sub Activity_Resume
'Code to get the notification tag after the user clicks on a notification.
Dim in As Intent = Activity.GetStartingIntent
If in.IsInitialized And in <> OldIntent Then
OldIntent = in
If in.HasExtra("Notification_Tag") Then
Log("Activity started from notification. Tag: " & in.GetExtra("Notification_Tag"))
End If
End If
End Sub
Sub Simple_Notification_Sound
Dim n As NB6
n.Initialize("default1", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(smiley)
n.SetDefaults(True,False,False)
n.Build("sound only", "sound only", "tag1", Me).Notify(1) 'It will be Main (or any other activity) instead of Me if called from a service.
End Sub
Sub Simple_Notification_Sound_Vib
Dim n As NB6
n.Initialize("default2", Application.LabelName,"DEFAULT").AutoCancel(True).SmallIcon(smiley)
'n.SetDefaults(True,False,True)
n.Build("sound and vib", "sound and vib", "tag2", Me).Notify(2)
End Sub
Sub Simple_Notification_Vib
Dim n As NB6
n.Initialize("default3", Application.LabelName,"DEFAULT").AutoCancel(True).SmallIcon(smiley)
n.SetDefaults(False, False, True)
n.Build("vib", "vib", "tag3", Me).Notify(3)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub