Sub ShowNotification2
Dim n As NB6
Dim NotifSound As String
Dim rp As RuntimePermissions
Dim Folder As String = rp.GetSafeDirDefaultExternal("shared")
n.Initialize("default", Application.LabelName, "HIGH").SmallIcon(NotifIcon)
n.BigPictureStyle(NotifImage.Resize(256dip, 256dip, True), NotifImage, NotifTitle, NotifBody)
n.Color(0xFF00AEFF)
NotifSound = "notification.mp3"
'copy the file to the shared folder
File.Copy(File.DirAssets, NotifSound, Folder, NotifSound)
'disable the default sound
n.SetDefaults(False, True, True)
'set custom sound
'n.CustomSound(CreateFileProviderUri(Folder, NotifSound))
Dim Obj As Object = CreateFileProviderUri(Folder, NotifSound)
n.CustomSound(Obj)
n.Build(NotifTitle, NotifBody, "tag", NotifActivity).Notify(1)
End Sub
Sub CreateFileProviderUri (Dir As String, FileName As String) As Object
Dim ObjFileProvider As JavaObject
Dim ObjContext As JavaObject
Dim ObjFile As JavaObject
Log ("Dir=" & Dir)
Log ("FileName=" & FileName)
ObjContext.InitializeContext
ObjFileProvider.InitializeStatic("android.support.v4.content.FileProvider")
ObjFile.InitializeNewInstance("java.io.File", Array(Dir, FileName))
Return ObjFileProvider.RunMethod("getUriForFile", Array(ObjContext, Application.PackageName & ".provider", ObjFile))
End Sub