Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notification with sound although phone is muted

I am creating a notification with Android's NotificationManager.

Is it possible to 'override' the phone's volume (mute) settings in such a way, that the notification's sound is ALWAYS played?

The reason I need this is the following: The notification is so important, that vibration alone may not be enough. The user MUST be alerted. So a sound shall be played, even if the phone is muted or the volume is very low.

like image 962
Boris Avatar asked Oct 14 '14 05:10

Boris


People also ask

Why is my phone making noises when on silent?

Question: Q: iphone 11 plays sound even when on silent mode First, check to see if Do Not Disturb is turned on. If it is turned on, check the setting for "Allow Calls From." If this is set to Favorites it will allow calls from those who are on your Favorites list.

Why does my iPhone still make noise when its on silent?

Your iPhone's audio system is apparently glitching because it still plays notification sounds even when it's already set to silent. Many people who have encountered the same issue for the first time have found a quick fix by simply switching silent mode off and then on again shortly.

Why does my phone make a noise but no notification iPhone?

ANSWER: Go to Settings/Reminders and look for Today Notification. This will chime at a set time for any All-Day reminders. Turn it off and your sounds may stop. Also check Settings/Notifications for apps that may have only Sound turned on and no Badges or Banners turned on as suggested in other answers.


1 Answers

yes it is possible,

MediaPlayer mMediaPlayer;
Uri notification = null;
notification = RingtoneManager
                .getDefaultUri(RingtoneManager.TYPE_ALARM);

mMediaPlayer = new MediaPlayer();
        mMediaPlayer.setDataSource(ctx, notification);
        // mMediaPlayer = MediaPlayer.create(ctx, notification);
        final AudioManager audioManager = (AudioManager) ctx
                .getSystemService(Context.AUDIO_SERVICE);

        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);

        mMediaPlayer.prepare();
        // mMediaPlayer.start();
        mMediaPlayer.setLooping(true);
        mMediaPlayer.setOnPreparedListener(new OnPreparedListener() {
            public void onPrepared(MediaPlayer arg0) {
                mMediaPlayer.seekTo(0);
                mMediaPlayer.start();

            }

        });
like image 58
Shreenivas Chikati Avatar answered Oct 07 '22 00:10

Shreenivas Chikati