I'm using the following code to play the ringtone using the media player. I'm adding an IF statement to play the Notifications sound but notifications doesn't work. I get a runtime error File Not Found Exception.
B4X:
Sub Play_Ringer
Dim r As Reflector
r.Target = "ContentDir"
r.Target = r.RunMethod("intern")
If Main.pPhoneType = "NONE" Then
mpp.Load(r.Target, "content://settings/system/notifications")
Else
mpp.Load(r.Target, "content://settings/system/ringtone")
End If
mpp.Play
End Sub
I saw this piece of code while searching for Notification playing examples. But this is for non-B4A Android. I wonder if this was converted to B4A if it would play the Notification sound?
B4X:
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
r.play();
I also tried these two lines (now remmed out) but they produced the same runtime error.
B4X:
Sub Play_Ringer
Dim r As Reflector
r.Target = "ContentDir"
r.Target = r.RunMethod("intern")
If Main.pPhoneType = "NONE" Then
'mpp.Load(r.Target, "content://settings/system/notification")
'mpp.Load(r.Target, "my.package.name/raw/notification")
Else
mpp.Load(r.Target, "content://settings/system/ringtone")
End If
mpp.Play
End Sub
I saw this piece of code while searching for Notification playing examples. But this is for non-B4A Android. I wonder if this was converted to B4A if it would play the Notification sound?
B4X:
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
r.play();
I also tried these two lines (now remmed out) but they produced the same runtime error.
B4X:
Sub Play_Ringer
Dim r As Reflector
r.Target = "ContentDir"
r.Target = r.RunMethod("intern")
If Main.pPhoneType = "NONE" Then
'mpp.Load(r.Target, "content://settings/system/notification")
'mpp.Load(r.Target, "my.package.name/raw/notification")
Else
mpp.Load(r.Target, "content://settings/system/ringtone")
End If
mpp.Play
End Sub
I saw this piece of code while searching for Notification playing examples. But this is for non-B4A Android. I wonder if this was converted to B4A if it would play the Notification sound?
B4X:
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
r.play();
I also tried these two lines (now remmed out) but they produced the same runtime error.
B4X:
Sub Play_Ringer
Dim r As Reflector
r.Target = "ContentDir"
r.Target = r.RunMethod("intern")
If Main.pPhoneType = "NONE" Then
'mpp.Load(r.Target, "content://settings/system/notification")
'mpp.Load(r.Target, "my.package.name/raw/notification")
Else
mpp.Load(r.Target, "content://settings/system/ringtone")
End If
mpp.Play
End Sub