4
My application needs the user to be able to choose at its beginning whether they want to hear the sounds of the app or not, because it is an app to be used in the classroom and in this environment the volume of the app should be reset.
So I created a AlertDialog
for as soon as the app runs the user decides whether or not to lower the volume, so:
AlertDialog.Builder dlg = new AlertDialog.Builder(ActDinamica.this);
dlg.setTitle("Bem Vindo!");
dlg.setMessage("Você está em aula?");
dlg.setPositiveButton("Sim", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Mute();
}
});
dlg.setNegativeButton("Não", null);
dlg.show();
Hence I need to configure this method Mute();
so that the volume of audio from mobile media goes to zero.
Method:
private void Mute() {
// codigo para o volume zerar?
}
Note: I found only methods to stop specific audios that were being executed...
Friend, first there was a mistake here (bold): [Audiomanager audioManager = (Audiomanager) context. getSystemService(Context.AUDIO_SERVICE);], after correcting this error based on the other answer to that question, it again did not work... But thank you!
– Tony Álaffe