Reputation: 813
I'm trying to change the volume control in my app. So I found out that I have to use the "setVolumeControlStream"
function in the onCreate method. Now I have a fragment and its not changing anything. Some ideas to get this method work?
What I tried: getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC);
Upvotes: 1
Views: 5182
Reputation: 9111
The documentation for setVolumeControlStream says:
The suggested audio stream will be tied to the window of this Activity.
So if you are creating a SurfaceView to play video, for example, then the SurfaceView has its own window separate from the Activity's window. The volume control setting on the Activity wouldn't affect the SurfaceView window which may have focus.
Upvotes: 2