I'm developing an Android app where the user is allowed to rest his hand on the device, and I want to disable physical buttons so the user don't get annoyed by unwanted clicks.
I've disabled the back, menu and search buttons with the following:
@Override public void onBackPressed() {} @Override public boolean onPrepareOptionsMenu(Menu menu) {return false;} @Override public boolean onSearchRequested() {return false;}
And I've learned that disabling the home key is unsupported and/or not adviced (although I'd like it to).
Ok, now I couldn't figure out how to disable the clicking sound for the keys I've disabled, they do nothing but keep ticking, is there a way to turn it off?
I'd like to mute it for my app only. If not possible, I'd like to know about alternatives that change system settings programmatically, to restore it latter on closing or on focus changing.
You can mute the sound when your app starts and unmute when it finishes
@override
public void onResume(){
super.onResume();
AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
mgr.setStreamMute(AudioManager.STREAM_SYSTEM, true);
}
@override
public void onPause(){
super.onPause();
AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
mgr.setStreamMute(AudioManager.STREAM_SYSTEM, false);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With