Answer the question
In order to leave comments, you need to log in
How to turn off sounds in the application?
In the application, I implemented the playback of a certain sound at a certain event.
MediaPlayer mp = MediaPlayer.create(activity, R.raw.my_sound);
mp.start();
AudioManager aManager=(AudioManager)getActivity().getSystemService(Context.AUDIO_SERVICE);
if(aManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT){
aManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
textView.setText("SOUND:OFF");
} else{
aManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
textView.setText("SOUND:ON");
}
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setVolume(0, 0);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question