I know that code below is the max volume
mAudioManager.getStreamMaxVolume
how can i get the minimum volume?
I used this code but not the minimum volume
mAudioManager.getStreamVolume(0);
This my code
int Minvolume=myAudioManager.getStreamVolume(0);
int current=myAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
int volume=(int) (current-1);
if (current>=Minvolume){
myAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0);
handler.postDelayed(this, 10000);
System.out.println("ADJUST LOWER");
}
else if (current!=Minvolume){
System.out.println("volume is minimum");
}
Try the following to reduce the volume of the music stream...
for (int volume = myAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) - 1; volume >= 0; volume--) {
//
// add your delay code here
//
// Call a method to set absolute volume
setVolume(volume);
}
private void setVolume(int volume) {
myAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0);
}