Search code examples
android

How to check Programmatically the volume of phone in android?


I am developing an application in which i will play music..Now i want to check whether the user has reduced the volume of the phone or not... I want the music to play at a particular volume...How to do it?


Solution

  • You can use AudioManager.getStreamVolume to fetch the current volume for the media player stream (See STREAM_MUSIC), and AudioManager.setStreamVolume to set it.