禁用声音只是一个应用程序 [英] Disable sound just for one application
问题描述
是否有可能关闭所有声音只是一个应用程序,并保存选择,直到应用程序的下一个开始?
Is it possible to turn off all sounds of just one app and to save the choice until the next start of the app?
所以,我必须在StartActivity和pressing此按钮切换按钮,应用程序的所有声音应该被取消,但其他应用程序的声音仍然应该工作。
So I have a ToggleButton at the StartActivity and by pressing this Button, all sounds of the app should be deactivated, but sounds of other apps should still be working.
我和preferences试了一下,使用共享preferences类,XML文件等,就像在我的书。但通过我意识到引进去,即preferences只是一种方式来保存数据永久的。 所以,我必须包括例如在拥有完善的每个按钮的if子句来检查,如果这样或那样的救preference声音开/关是真/假,然后激活/关闭声音?
I tried it with Preferences, using the SharedPreferences class, an xml file and so on, like in my book. But going through the introduction i realized, that the Preferences are just a way to save data permanent. So I would have to include for example on every Button with a sound an if-clause that checks if this or that saved preference for sound on/off is true/false and then activates/deactivates the sound?
我认为这可能是更容易?
I thought that it could be easier?
推荐答案
其实,如果你想在你的应用程序中禁用的声音 - 你可以不玩了。你可以存储标志每种声音要在共享preferences玩
,你想播放声音,每次检查。这真的很容易!
Actually, if you want to disable a sound in your application - you can just don't play it. You can store the flags for each sound you want to play in the SharedPreferences
and check it every time you want to play a sound. It's really easy!
这篇关于禁用声音只是一个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!