'Build the notification and returns the notification object.
'ContentTitle - Title (CharSequence)
'ContentText - Body text (CharSequence)
'Tag - Tag that can be intercepted in Activity_Resume (or Service_Start) when the user clicks on the notificaiton.
'Activity - The activity that will be launched when the user clicks on the notification. Set to null if not used
'Service - The service module name that will receive notification when the user clicks on the notification. Set to "" if not used
Public
Sub Build (ContentTitle As Object, ContentText As Object, Tag As String, Activity As Object, Service As String) As Notification
If IsOld Then
OldNotification.SetInfo2(ContentTitle, ContentText, Tag, Activity)
Return OldNotification
Else
If Not(IsChannel) And nDefaults <> 7 Then 'not all true
Log("nDefaults = " & nDefaults)
NotificationBuilder.RunMethod("setDefaults", Array(nDefaults))
End If
If Activity <> Null Then
Dim in As Intent = CreateIntent(Activity, False)
in.Flags = Bit.Or(268435456, 131072) 'FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_REORDER_TO_FRONT
in.PutExtra("Notification_Tag", Tag)
Dim PendingIntent As Object = PendingIntentStatic.RunMethod("getActivity", Array(ctxt, Rnd(0, 0x7fffffff), in, 0))
NotificationBuilder.RunMethod("setContentIntent", Array(PendingIntent))
'added for service
else If Service <> "" And Tag <> "" Then
Dim srvIn As Intent
srvIn.Initialize("", "")
srvIn.SetComponent(Application.PackageName & "/." & Service.ToLowerCase)
srvIn.PutExtra("Notification_Tag", Tag)
Dim SrvPendingIntent As Object = PendingIntentStatic.RunMethod("getService", Array(ctxt, 1, srvIn, 1073741824))
NotificationBuilder.RunMethod("setContentIntent", Array(SrvPendingIntent))
End If
NotificationBuilder.RunMethodJO("setContentTitle", Array(ContentTitle)).RunMethodJO("setContentText", Array(ContentText))
If IsChannel Then
Dim manager As JavaObject = ctxt.RunMethod("getSystemService", Array("notification"))
If NotifChannelGroup.IsInitialized Then
manager.RunMethod("createNotificationChannelGroup", Array(NotifChannelGroup))
Channel.RunMethod("setGroup", Array(groupID))
End If
manager.RunMethod("createNotificationChannel", Array(Channel))
End If
Return NotificationBuilder.RunMethod("build", Null)
End If
End Sub