Android Question [SOLVED] How to Copy a Ringtone to File.Assets

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi All

I have an app that will have a Phone Call Open. When a SMS arrives in I do not get the notification sound, just a vibration.

I have tried:

B4X:
Sub play_default_notification
   
   Dim rm As RingtoneManager
   PlayRingtone(rm.GetDefault(rm.TYPE_NOTIFICATION))

End Sub

Sub PlayRingtone(url As String)

   Dim jo As JavaObject
   jo.InitializeStatic("android.media.RingtoneManager")
   Dim jo2 As JavaObject
   jo2.InitializeContext
   
   mod_media.set_mode(mod_media.MODE_NORMAL)
   Dim u As Uri
   u.Parse(url)
   jo.RunMethodJO("getRingtone", Array(jo2, u)).RunMethod("play", Null)
   
   
End Sub

The notification will not play. I now think if I can copy the default notification file to the file assets folder then I can play it with media player.

Help appreciated

Regards

John.
 

Star-Dust

Expert
Licensed User
Longtime User
You can not write to the Assest folder. It's not a real folder. And it's a read only folder.

But you can copy the melody to another folder. Try File.DirInternat, I think it should work with the Audio Library
B4X:
Dim A As MediaPlayer
A.Load(File.DirInternal,"mysound.mp3")
 
Upvote 0
Top