Reputation: 561
At the moment I am using the following to put the phone into Silent Mode:
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
But I have noticed that in Lollipop it puts the phone into "Priority Mode" with a little star at the top in the notification bar. But I want it to be 100% silent and not "Priority Mode". Is this possible? To set Lollipop to be 100% silent?
I have tried to set the setRingerMode to 0 like this
audioManager.setRingerMode(0);
But it still gives me the star instead of the the speaker with the line through it and it says Vibrate with (Priority) in brackets under it.
Upvotes: 2
Views: 2284
Reputation: 23
I have solved this problem by calling setRingerMode(AudioManager.RINGER_MODE_SILENT)
twice because Lollipop first places the device into Priority mode than into Silent mode.
final AudioManager audiomanage = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
audiomanage.setRingerMode(AudioManager.RINGER_MODE_SILENT);
new Thread(new Runnable() {
public void run()
{
try
{
Thread.sleep(100);
audiomanage.setRingerMode(AudioManager.RINGER_MODE_SILENT);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}).start();
Upvotes: 0
Reputation: 2783
In Android 5.0.X, calling setRingerMode(RINGER_MODE_SILENT)
would (i) trigger the "priority mode", which would (ii) subsequently trigger a change of the ringer mode back to RINGER_MODE_NORMAL.
A brutal workaround, exploiting a bug in Android 5.0.X, is to issue the setRingerMode(RINGER_MODE_SILENT)
call again in a short time (say 500ms) after action (ii) above is triggered. But this is of course not proper and should cease to work in Android 5.1.X.
The proper way to achieve 100% silence in 5.X would be to switch to the "None" interruption mode. This could be achieved by creating a service extending NotificationListenerService
, registering it, and providing a function to set the interruption mode by calling requestInterruptionFilter(INTERRUPTION_FILTER_NONE)
in the service. Here (Noyze app) is an example. You can then invoke the function from your activity to switch to the mode.
For this to work you would need the BIND_NOTIFICATION_LISTENER_SERVICE
permission, and an explicit grant of notification access by the user.
Caution: as you may be aware INTERRUPTION_FILTER_NONE
really means 100% silence, and Alarm clock would cease to work.
Upvotes: 5
Reputation: 1269
Google has removed silent mode from lollipop. Here is the link to official android issue page.
Setting the device to RINGER_MODE_SILENT causes the device to enter the new priority mode. The device leaves priority mode if you set it to RINGER_MODE_NORMAL or RINGER_MODE_VIBRATE.
You read more about it here.
Upvotes: 0