For my iAndroidRemote project, I had to adjust the volume of my Android phone. I found the code after digging around a bit.
I thought of sharing the code here, so that it would be useful for others and also I would know where to look for it when I need it for the next time.
Changing the volume in Android is pretty easy. You just need to know which class and method to call.
Getting the AudioManager Instance
First you have to get an instance of the
AudioManager. You can get it by calling the
getSystemService method of the
Context object. If you are inside an Activity, you can get the instance by making the following code