@Override
 public boolean onCreateOptionsMenu(Menu menu) {
   AudioManager audio =
       (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
   audio.playSoundEffect(Sounds.DISALLOWED);
   return false;
 }
 private void playClick(int keyCode) {
   AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE);
   switch (keyCode) {
     case 32:
       am.playSoundEffect(AudioManager.FX_KEYPRESS_SPACEBAR);
       break;
     case Keyboard.KEYCODE_DONE:
     case 10:
       am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);
       break;
     case Keyboard.KEYCODE_DELETE:
       am.playSoundEffect(AudioManager.FX_KEYPRESS_DELETE);
       break;
     default:
       am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD);
   }
 }
  @Override
  public void keypadPress(EditText etInput, char character) {
    if (vibrateFeedback) {
      etInput.performHapticFeedback(
          HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
    }

    if (audioManager != null) {
      audioManager.playSoundEffect(AudioManager.FX_KEY_CLICK, -1.0f);
    }

    super.keypadPress(etInput, character);
  }
Beispiel #4
0
 public void playSound(final int code) {
   if (soundOn && (audioManager != null)) {
     final int sound;
     switch (code) {
       case KeyEvent.KEYCODE_DEL:
         sound = AudioManager.FX_KEYPRESS_DELETE;
         break;
       case KeyEvent.KEYCODE_ENTER:
         sound = AudioManager.FX_KEYPRESS_RETURN;
         break;
       case KeyEvent.KEYCODE_SPACE:
         sound = AudioManager.FX_KEYPRESS_SPACEBAR;
         break;
       default:
         sound = AudioManager.FX_KEYPRESS_STANDARD;
         break;
     }
     audioManager.playSoundEffect(sound, volume);
   }
 }
 private void playKeyClick(int primaryCode) {
   // if mAudioManager is null, we can't play a sound anyway, so return
   if (mAudioManager == null) return;
   if (mSoundOn) {
     final int sound;
     switch (primaryCode) {
       case Keyboard.CODE_DELETE:
         sound = AudioManager.FX_KEYPRESS_DELETE;
         break;
       case Keyboard.CODE_ENTER:
         sound = AudioManager.FX_KEYPRESS_RETURN;
         break;
       case Keyboard.CODE_SPACE:
         sound = AudioManager.FX_KEYPRESS_SPACEBAR;
         break;
       default:
         sound = AudioManager.FX_KEYPRESS_STANDARD;
         break;
     }
     mAudioManager.playSoundEffect(sound, mSettingsValues.mFxVolume);
   }
 }
Beispiel #6
0
 public void playThemeEffect(int soundConstant) {
   m_audioManager.playSoundEffect(soundConstant);
 }
 public void playSoundEffect(int soundConstant) {
   mAudioManager.playSoundEffect(soundConstant, ActivityManager.getCurrentUser());
 };
  @TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "unloadSoundEffects",
        args = {}),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "playSoundEffect",
        args = {int.class}),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "playSoundEffect",
        args = {int.class, float.class}),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "loadSoundEffects",
        args = {}),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "setRingerMode",
        args = {int.class})
  })
  public void testSoundEffects() throws Exception {
    // set relative setting
    mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
    Settings.System.putInt(mContext.getContentResolver(), SOUND_EFFECTS_ENABLED, 1);

    // should hear sound after loadSoundEffects() called.
    mAudioManager.loadSoundEffects();
    Thread.sleep(TIME_TO_PLAY);
    float volume = 13;
    mAudioManager.playSoundEffect(SoundEffectConstants.CLICK);
    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_UP);
    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_DOWN);
    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_LEFT);
    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_RIGHT);

    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_UP, volume);
    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_DOWN, volume);
    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_LEFT, volume);
    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_RIGHT, volume);

    // won't hear sound after unloadSoundEffects() called();
    mAudioManager.unloadSoundEffects();
    mAudioManager.playSoundEffect(AudioManager.FX_KEY_CLICK);
    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_UP);
    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_DOWN);
    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_LEFT);
    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_RIGHT);

    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_UP, volume);
    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_DOWN, volume);
    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_LEFT, volume);
    mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_RIGHT, volume);
  }
 private void playSuccessSound() {
   audioManager.playSoundEffect(Sounds.SUCCESS);
 }
 private void playNavigationSound() {
   audioManager.playSoundEffect(Sounds.SELECTED);
 }