2

I'm wondering, if there is any predefined sounds in Android that I can use in my application.

I was trying to use a class called SoundManager which is build specifically for sound playing in an efficient way.

I realized that what I need is much much smaller than this class. I need a click sound when the button is clicked and a navigation sound when the user navigate through a menu or a set of buttons.

I guess there is something in the android API fit to my purpose but I could not find it. any help please in finding it and hoe to use it?

Nikki
  • 3,314
  • 13
  • 36
  • 59
iTurki
  • 16,292
  • 20
  • 87
  • 132

2 Answers2

3

You could look into the View.playSoundEffect api. This method accepts a SoundEffectConstants value where, among others, a CLICK constant is available.

Peter Lillevold
  • 33,668
  • 7
  • 97
  • 131
  • This is exactly what I want. I knew there is something like this but I could not find it. I didn't test it but I hope it will work with me. Thanks @Peter :) – iTurki Jun 30 '11 at 18:29
  • @2rk - that's great. Perhaps you could share your findings here when you get it to work? Good luck! – Peter Lillevold Jul 01 '11 at 08:16
  • 1
    I'm still trying to figure out another problem. Then, I will update this. This method won't work unless the `phone's Audible Selection` is _enabled_. You may can help here [link](http://stackoverflow.com/q/6555410/543711) – iTurki Jul 02 '11 at 07:02
0

Using the MediaPlayer it's really simple, see for instance this SO thread: Android - play sound on button click - Null pointer exception

Community
  • 1
  • 1
Stefan H Singer
  • 5,469
  • 2
  • 25
  • 26