Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control volume in android?

Android has the Hardware button for controlling volume (increase/decrease). I want to same functionality by using buttons in my application with visual volume control and it should be disappeared after some time (in sec).

like image 301
Sandy Avatar asked Feb 25 '11 12:02

Sandy


People also ask

How can I control my phone volume without volume button?

Open Settings on your Android phone by clicking the gear icon. Then, head over to the sound and vibrations option. You will see a few volume sliders adjusting the volume of media, ringtone, notifications, and alarms, now you just need to adjust the volume and that's it.

How do I control sound volume?

To change the sound volume, open the system menu from the right side of the top bar and move the volume slider left or right. You can completely turn off sound by dragging the slider to the left. Some keyboards have keys that let you control the volume.

How do I get more control volume on my phone?

Volume Control is one very feature-rich app that will give you full control over the volume settings. For example, by swiping down from the top of the display, you'll see the volume settings for the alarm, multimedia, notifications, ringer, system, calls, and Bluetooth.


1 Answers

You need to use the AudioManager class. Developer doc is here. Depending on which volume you want to adjust (ringer/media) you may need to change the audiomode via AudioManager.

Finally, to make the buttons disappear just use View.GONE on them. I would create a Runnable in the onClickListener and use a postDelayed to make the View disappear.

like image 78
user432209 Avatar answered Sep 20 '22 16:09

user432209