Disabling system sounds

Android has default sounds for button clicks. If you want to use your own sounds for the click action, you also have to disable the system sounds. This is something that we will want almost every time. Luckily it is very easy to do. We just have to modify the application style we have already defined in res/styles.xml and tell it that we want to disable sound effects:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  <item name="android:soundEffectsEnabled">false</item>
</style>

Get Android Game Programming: A Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.