简体   繁体   中英

How to mute incoming call in android 5

How can I mute phone ring in 5.1 ?

I have the following codes.
AudioManager audiomanage = (AudioManager)lfrag.getActivity().getSystemService(Context.AUDIO_SERVICE); audiomanage.setRingerMode(AudioManager.RINGER_MODE_SILENT);

and give this permission in manifest
< uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

But it did work. Please help.

Here is the solution for you

AudioManager am;
am= (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE);
//For Normal mode
am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);

//For Silent mode
am.setRingerMode(AudioManager.RINGER_MODE_SILENT);

//For Vibrate mode
am.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM