Android examples for Media:Sound
play Key Click Audio Sound
//package com.java2s; import android.content.Context; import android.media.AudioManager; public class Main { private static final Object mSingletonLock = new Object(); private static AudioManager audioManager; public static void playKeyClickSound(Context context, int volume) { if (volume == 0) return; getInstance(context).playSoundEffect(AudioManager.FX_KEY_CLICK, (float) volume / 100.0f); }//from w w w . ja v a2 s . c o m private static AudioManager getInstance(Context context) { synchronized (mSingletonLock) { if (audioManager != null) return audioManager; if (context != null) audioManager = (AudioManager) context .getSystemService(Context.AUDIO_SERVICE); return audioManager; } } }