0

I'm trying to disable system sound effects when a user clicks on a tab in my TabHost and to set my own custom sound. So I tried this to disable the system sound effect:

TabHost tabHost = getTabHost();
tabHost.setSoundEffectsEnabled(false);

And this is my code to play my custom sound:

tabHost.setOnTabChangedListener(new OnTabChangeListener() {
    public void onTabChanged(String tabId) {
        SoundUtility.getInstance(MainActivity.this).playPositive();
    }
});

My custom sound does play, but also the system sound effect, it's not being disabled. So I actually have 2 sounds overlapping each other. So how do I disable the system sound effect?

Igal
  • 5,833
  • 20
  • 74
  • 132
  • have you try it on tabChangeListener ?? – Shreyash Mahajan Dec 22 '12 at 11:36
  • @iDroidExplorer Yup, tried it. Tried to use `tabHost.setSoundEffectsEnabled(false);` on tabChangeListener, also tried to disable it on the currently pressed tab (but didn't write the code right, the app crashed). – Igal Dec 22 '12 at 11:55
  • can you put that code ? and also show at which line you got crashed. – Shreyash Mahajan Dec 22 '12 at 12:21
  • @iDroidExplorer I already deleted this code... I just tried this code: `TabWidget tw = (TabWidget) tabHost.getTabWidget(); tw.setSoundEffectsEnabled(false);` both in onCreate and in onTabChangeListener, but still no luck. – Igal Dec 22 '12 at 12:41
  • have you refer this: http://stackoverflow.com/questions/10237097/play-sound-on-tab-click – Shreyash Mahajan Dec 22 '12 at 13:06
  • Well, they show how to play a custom sound and I already do that. My problem is how to disable the system sound effect, to hear only my sound, not android's native sound as well... – Igal Dec 22 '12 at 13:19
  • I got the same problem, and i found this [a good solution][1] [1]: http://stackoverflow.com/a/5504676/1048872 – lynn8570 Jan 16 '13 at 07:27

0 Answers0