List of usage examples for android.media AudioManager FX_KEY_CLICK
int FX_KEY_CLICK
To view the source code for android.media AudioManager FX_KEY_CLICK.
Click Source Link
From source file:Main.java
public static void playKeyPress(Context c) { AudioManager am = (AudioManager) c.getSystemService(Context.AUDIO_SERVICE); am.playSoundEffect(AudioManager.FX_KEY_CLICK, (float) 0.25); }
From source file:Main.java
public static void playKeyClickSound(Context context, int volume) { if (volume > 0) getInstance(context).playSoundEffect(AudioManager.FX_KEY_CLICK, (float) volume / 100.0f); }
From source file:Main.java
public static void playKeyClickSound(Context context, int volume) { if (volume == 0) return;/*from w ww . j a v a 2 s .c o m*/ getInstance(context).playSoundEffect(AudioManager.FX_KEY_CLICK, (float) volume / 100.0f); }
From source file:edu.ucdavis.glass.sepsis.support.OverviewActivity.java
private GestureDetector createGestureDetector(Context context) { GestureDetector gestureDetector = new GestureDetector(context); // create a base listener for generic gestures gestureDetector.setBaseListener(new GestureDetector.BaseListener() { @Override/*from w w w .j a va 2s.co m*/ public boolean onGesture(Gesture gesture) { if (gesture == Gesture.TAP) { mAudioManager.playSoundEffect(AudioManager.FX_KEY_CLICK); // set up AsyncTask AsyncTask<String, Void, JSONObject> JSON = new LoadJSONAsyncTask((Context) mContext, "Updating all patient's info...", mContext); // run AsyncTask JSON.execute(Global.recentPatients.peek().id); return true; } else if (gesture == Gesture.SWIPE_RIGHT) { finish(); mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_RIGHT); startActivity(new Intent(getApplicationContext(), VitalsActivity.class)); return true; } else if (gesture == Gesture.SWIPE_LEFT) { finish(); mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_LEFT); startActivity(new Intent(getApplicationContext(), SupportActivity.class)); return true; } return false; } }); return gestureDetector; }
From source file:de.questmaster.fatremote.fragments.RemoteFragment.java
private void invokeSend() { // ring / vibrate if (!mSettings.isOverride() && mAudioManager.getStreamVolume(AudioManager.STREAM_SYSTEM) != 0 || (mSettings.isOverride() && mSettings.isTone())) { mAudioManager.playSoundEffect(AudioManager.FX_KEY_CLICK, 0.5f); }/*from w ww. j a v a2 s. c o m*/ if (mSettings.isVibrate()) { Vibrator vibrator = (Vibrator) c.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(25); } // Set sending image ImageView sending = (ImageView) c.findViewById(R.id.sendLED); sending.setImageResource(R.drawable.light_highlight); sending.invalidate(); // start sending NetworkProxy.getInstance(c).addRemoteEvent(new FATRemoteEvent(keyCode, keyModifier)); }
From source file:android.support.v7.app.AppCompatDelegateImplV7.java
private void onKeyUpPanel(int featureId, KeyEvent event) { if (mActionMode != null) { return;/*from ww w . j a v a 2s. c o m*/ } boolean playSoundEffect = false; final PanelFeatureState st = getPanelState(featureId, true); if (featureId == FEATURE_OPTIONS_PANEL && mDecorContentParent != null && mDecorContentParent.canShowOverflowMenu() && !ViewConfigurationCompat.hasPermanentMenuKey(ViewConfiguration.get(mContext))) { if (!mDecorContentParent.isOverflowMenuShowing()) { if (!isDestroyed() && preparePanel(st, event)) { playSoundEffect = mDecorContentParent.showOverflowMenu(); } } else { playSoundEffect = mDecorContentParent.hideOverflowMenu(); } } else { if (st.isOpen || st.isHandled) { // Play the sound effect if the user closed an open menu (and not if // they just released a menu shortcut) playSoundEffect = st.isOpen; // Close menu closePanel(st, true); } else if (st.isPrepared) { boolean show = true; if (st.refreshMenuContent) { // Something may have invalidated the menu since we prepared it. // Re-prepare it to refresh. st.isPrepared = false; show = preparePanel(st, event); } if (show) { // Show menu openPanel(st, event); playSoundEffect = true; } } } if (playSoundEffect) { AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); if (audioManager != null) { audioManager.playSoundEffect(AudioManager.FX_KEY_CLICK); } else { Log.w(TAG, "Couldn't get audio manager"); } } }
From source file:android.support.v7ox.app.AppCompatDelegateImplV7.java
private boolean onKeyUpPanel(int featureId, KeyEvent event) { if (mActionMode != null) { return false; }//from w ww. ja v a2 s.c o m boolean handled = false; final PanelFeatureState st = getPanelState(featureId, true); if (featureId == FEATURE_OPTIONS_PANEL && mDecorContentParent != null && mDecorContentParent.canShowOverflowMenu() && !ViewConfigurationCompat.hasPermanentMenuKey(ViewConfiguration.get(mContext))) { if (!mDecorContentParent.isOverflowMenuShowing()) { if (!isDestroyed() && preparePanel(st, event)) { handled = mDecorContentParent.showOverflowMenu(); } } else { handled = mDecorContentParent.hideOverflowMenu(); } } else { if (st.isOpen || st.isHandled) { // Play the sound effect if the user closed an open menu (and not if // they just released a menu shortcut) handled = st.isOpen; // Close menu closePanel(st, true); } else if (st.isPrepared) { boolean show = true; if (st.refreshMenuContent) { // Something may have invalidated the menu since we prepared it. // Re-prepare it to refresh. st.isPrepared = false; show = preparePanel(st, event); } if (show) { // Show menu openPanel(st, event); handled = true; } } } if (handled) { AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); if (audioManager != null) { audioManager.playSoundEffect(AudioManager.FX_KEY_CLICK); } else { Log.w(TAG, "Couldn't get audio manager"); } } return handled; }
From source file:com.anysoftkeyboard.AnySoftKeyboard.java
public void onPress(int primaryCode) { super.onPress(primaryCode); InputConnection ic = getCurrentInputConnection(); if (mVibrationDuration > 0 && primaryCode != 0 && mVibrator != null) { try {//from w w w . j a va 2s. c om mVibrator.vibrate(mVibrationDuration); } catch (Exception e) { Logger.w(TAG, "Failed to interact with vibrator! Disabling for now."); mVibrationDuration = 0; } } if (primaryCode == KeyCodes.SHIFT) { mShiftKeyState.onPress(); handleShift(); } else { mShiftKeyState.onOtherKeyPressed(); } if (primaryCode == KeyCodes.CTRL) { mControlKeyState.onPress(); handleControl(); sendKeyDown(ic, 113); // KeyEvent.KEYCODE_CTRL_LEFT (API 11 and up) } else { mControlKeyState.onOtherKeyPressed(); } if (mSoundOn && (!mSilentMode) && primaryCode != 0) { final int keyFX; switch (primaryCode) { case 13: case KeyCodes.ENTER: keyFX = AudioManager.FX_KEYPRESS_RETURN; break; case KeyCodes.DELETE: keyFX = AudioManager.FX_KEYPRESS_DELETE; break; case KeyCodes.SPACE: keyFX = AudioManager.FX_KEYPRESS_SPACEBAR; break; default: keyFX = AudioManager.FX_KEY_CLICK; } final float fxVolume; // creating scoop to make sure volume and maxVolume // are not used { final int volume; final int maxVolume; if (mSoundVolume > 0) { volume = mSoundVolume; maxVolume = 100; fxVolume = ((float) volume) / ((float) maxVolume); } else { fxVolume = -1.0f; } } mAudioManager.playSoundEffect(keyFX, fxVolume); } }
From source file:com.codename1.impl.android.AndroidImplementation.java
/** * @inheritDoc//from w w w .j av a 2 s .c o m */ public void playBuiltinSound(String soundIdentifier) { if (getActivity() != null && Display.SOUND_TYPE_BUTTON_PRESS == soundIdentifier) { getActivity().runOnUiThread(new Runnable() { public void run() { if (myView != null) { myView.getAndroidView().playSoundEffect(AudioManager.FX_KEY_CLICK); } } }); } }