'theType: -1=Stop, 0=Notification, 1=Alarm, 2=Ringtone
Sub UseRingtone(theType As Int, Optional FullVolume As Boolean = True)
Private p As Phone, V As Int , NotificationManager As JavaObject, RM As RingtoneManager
Select Case theType
Case -1'STOP
Log("STOP PLAYING!")
Return
Case 0
theType = RM.TYPE_NOTIFICATION
V = p.VOLUME_NOTIFICATION
Case 1
theType = RM.TYPE_ALARM
V = p.VOLUME_ALARM
Case 2
theType = RM.TYPE_RINGTONE
v = p.VOLUME_RING
End Select
If FullVolume And p.SdkVersion >= 24 Then
NotificationManager = NotificationManager.InitializeContext.RunMethod("getSystemService", Array("notification"))
If NotificationManager.RunMethod("isNotificationPolicyAccessGranted", Null) = True Then
p.SetVolume(V , p.GetMaxVolume(V), False)
End If
End If
RM.Play(RM.GetDefault(theType))
End Sub