Hello
I am having an issue on Android 9 with the playing of custom sounds and NB6.
Code for selecting Sound
Code for Playing sound:
This works on Mi A2 Lite (Android 9), not on a One Plus 6 (Android 9), not a Google Pixel 9.0 Preview image running on a Genymotion emulator. On the one that do not work the default sound is played.
All works fine on Android 7,8.
Any idea's
Regards
John.
I am having an issue on Android 9 with the playing of custom sounds and NB6.
Code for selecting Sound
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private rm As RingtoneManager
End Sub
Sub ToolBar_MenuItemClick (Item As ACMenuItem)
If Item.Id = 2 Then
' // Get a notification
rm.ShowRingtonePicker("rm", rm.TYPE_NOTIFICATION, True, mod_core_consts.APPSET.notification_content )
End If
End Sub
Sub rm_PickerResult (Success As Boolean, Uri As String)
If Success Then
' // store URI
mod_core_consts.APPSET.notification_content = Uri
mod_settings.put_notification_content
Else
ToastMessageShow("Error loading ringtone.", True)
End If
End Sub
Code for Playing sound:
B4X:
Sub BigText_Notification(m As helloMessage)
Dim n As NB6
Dim cs As CSBuilder
Dim nm As Notification
If lastNotification = 0 Then
lastNotification = DateTime.now
End If
n.Initialize("atlas_hello_message", Application.LabelName, "DEFAULT").SmallIcon(notifyIcon).BadgeIconType("SMALL")
' // setcustom sound
If mod_core_consts.APPSET.notification_content <> "" Then
n.SetDefaults(False,True,True)
Dim uri As Uri
uri.Parse(mod_core_consts.APPSET.notification_content)
n.CustomSound(uri)
Else
' // use default sound
n.SetDefaults(True,True,True)
End If
n.OnlyAlertOnce(False)
n.AutoCancel(True)
mod_core_consts.APPSET.profile.notification_message_id = m.msgID
' // is this the messages thread we are viewing
If mod_core_consts.APPSET.profile.current_message_store_view = m.fromID Then
CallSubDelayed(MessagingItems,"insert_last_message")
Else
Dim p As Phone
' // 6+
If p.SdkVersion >= 23 Then
' // setup notification
If m.msgText.Length > 30 Then
' // long message
n.BigTextStyle(m.fromName, cs.Initialize.BackgroundColor(Colors.white).Append("Expand").PopAll, m.msgText)
svc_service.nNewMessage = n.Build(m.fromName, m.msgText.SubString2(0,29) & "...", m.msgID , MessagingItems)
Else
' // short message
svc_service.nNewMessage = n.Build(m.fromName, m.msgText, m.msgID, MessagingItems)
End If
Else
' // 5.1.1-
nm.Initialize
nm.AutoCancel = True
nm.Icon = "ic_chat_bubble_outline_white_24dp"
nm.Number = svc_service.nNewMessageID
' // this will include the messageId so the MessageItems Activity can insert the newest message via the intent handler
nm.SetInfo2(m.fromName, m.msgText,m.msgID, MessagingItems)
' // show notification
svc_service.nNewMessage = nm
End If
' // notify
CallSubDelayed(svc_service,"new_message_notification")
End If
End Sub
This works on Mi A2 Lite (Android 9), not on a One Plus 6 (Android 9), not a Google Pixel 9.0 Preview image running on a Genymotion emulator. On the one that do not work the default sound is played.
All works fine on Android 7,8.
Any idea's
Regards
John.