You can do it by yourself. Nothing complicated in it.
Once your PendingIntent
is triggered, make use of handlers to do the increasing.
Create class that will take the
AudioManager
orContext
of the app as argument.public class VolumeRunnable implements Runnable{ private AudioManager mAudioManager; private Handler mHandlerThatWillIncreaseVolume; private final static int DELAY_UNTILL_NEXT_INCREASE = 30*1000;//30 seconds between each increment VolumeRunnable(AudioManager audioManager, Handler handler){ this.mAudioManager = audioManager; this.mHandlerThatWillIncreaseVolume = handler; } @Override public void run(){ int currentAlarmVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_ALARM); if(currentAlarmVolume != mAudioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM)){ //if we havent reached the max //here increase the volume of the alarm stream by adding currentAlarmVolume+someNewFactor mHandlerThatWillIncreaseVolume.postDelayed(this,DELAY_UNTILL_NEXT_INCREASE); //"recursively call this runnable again with some delay between each increment of the volume, untill the condition above is satisfied. } }
}
Call this
Runnable
once thePendingIntent
is triggered:
someHandler.post(new VolumeRunnable(mAudioManager, someHandler));
I hope this gave you idea. Forgive any mistakes or typos.