安卓设置中有UI touch的提示音,在按下物理按键的时候也会出现。
设置和获取的方法:
//设置 0-关闭,1-打开 Settings.System.putInt(getContentResolver(), Settings.System.SOUND_EFFECTS_ENABLED, 0); //获取 int enabled = Settings.System.getInt(getContentResolver(), Settings.System.SOUND_EFFECTS_ENABLED);
播放代码位于framework/base/media/java/android/media/AudioManager.java
public void playSoundEffect(int effectType) { if (effectType < 0 || effectType >= NUM_SOUND_EFFECTS) { return; } if (!querySoundEffectsEnabled()) { return; } IAudioService service = getService(); try { service.playSoundEffect(effectType); } catch (RemoteException e) { Log.e(TAG, "Dead object in playSoundEffect"+e); } }