How can I silence the android phone in java? A code sample is VERY helpful.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
You can use the
AudioManager
class.In this class you're looking for
setRingerMode()
function.The values you can pass into the function are:
You have to add this into the manifest file:
Use the
AudioManager
class's methods to silence audio.For instance, to turn off the ringer use
manager.setRingerMode(AudioManager.RINGER_MODE_SILENT)
You can get an instance of the
AudioManager
by callingContext.getSystemService(Context.AUDIO_SERVICE)
http://developer.android.com/reference/android/media/AudioManager.html#setRingerMode(int)