Question

In my Android application, I would like to save the current speaker/mic volume level so that I can set it to the same level next time the application is run. I am wondering if there is any API to get/set speaker/mic volume levels.

Was it helpful?

Solution

AudioManager seems to do what you need for the speaker volume. You can use the getStreamVolume method in conjuction with one of the STREAM_X constants to get the volume you need and store it with SharedPreferences.

To set it afterwards, use the setStreamVolume method with the correct constant.

OTHER TIPS

You can use SharedPreferences for this task. Standard documentation has lots of information about it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top