Beep like function?

hackhack

Active Member
Licensed User
Longtime User
Is there a way to play a beep sound without having to use external files? (like wav or midi)
 
Pity, it increases size.

Unless there are sound files in Android one can use? You know like Windows installs a set of beeps and pings for use in user interface?
 
Upvote 0
Actually I read that one can use the ringtones, like

Code:
MediaPlayer player = MediaPlayer.create(this,
    Settings.System.DEFAULT_RINGTONE_URI);
player.start();

Though more relevant would perhaps be DEFAULT_NOTIFICATION_URI - now to see if this works in b4a :)
 
Upvote 0
Hm, I see on both my phone and tablet in

Code:
/system/media/audio/

There are several audio files already in place.
 
Upvote 0
Currently you will not be able to use it with Basic4android.
Ahem! actually ...

Code:
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
 
Upvote 0
Better add some tags so people can find it if they search: play default notification sound audio

Ahem! actually ...

Code:
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
 
Upvote 0
Funny though, it crashes the emulator with a java.lang.NullPointerException but works fine on the phone.
 
Upvote 0
Ahem! actually ...

Code:
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?
 
Upvote 0
Back
Top