MediaPlayer player = MediaPlayer.create(this,
Settings.System.DEFAULT_RINGTONE_URI);
player.start();
Ahem! actually ...Currently you will not be able to use it with Basic4android.
Sub Btn1_Click
Dim Obj1 As Reflector
Obj1.Target = Obj1.CreateObject("android.provider.Settings$System")
Obj1.Target = Obj1.GetField("DEFAULT_NOTIFICATION_URI")
Dim args(2) As Object
args(0) = Obj1.GetContext
args(1) = Obj1.Target
Dim types(2) As String
types(0) = "android.content.Context"
types(1) = "android.net.Uri"
Obj1.Target = Obj1.RunStaticMethod("android.media.MediaPlayer", "create", args, types)
Obj1.RunMethod("start")
End Sub
Ahem! actually ...
B4X:Sub Btn1_Click Dim Obj1 As Reflector Obj1.Target = Obj1.CreateObject("android.provider.Settings$System") Obj1.Target = Obj1.GetField("DEFAULT_NOTIFICATION_URI") Dim args(2) As Object args(0) = Obj1.GetContext args(1) = Obj1.Target Dim types(2) As String types(0) = "android.content.Context" types(1) = "android.net.Uri" Obj1.Target = Obj1.RunStaticMethod("android.media.MediaPlayer", "create", args, types) Obj1.RunMethod("start") End Sub
Not much experience with reflection & system settings, but is it possible to use code similar to this example to setfield (assign default notification) instead of getfield to read it?Ahem! actually ...
B4X:Sub Btn1_Click Dim Obj1 As Reflector Obj1.Target = Obj1.CreateObject("android.provider.Settings$System") Obj1.Target = Obj1.GetField("DEFAULT_NOTIFICATION_URI") Dim args(2) As Object args(0) = Obj1.GetContext args(1) = Obj1.Target Dim types(2) As String types(0) = "android.content.Context" types(1) = "android.net.Uri" Obj1.Target = Obj1.RunStaticMethod("android.media.MediaPlayer", "create", args, types) Obj1.RunMethod("start") End Sub