I assume you wanted more information than just how to make a Toast. So here are few other pointers.
To access the volume level use AudioManager:
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
int currentVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC);
Catching the volume buttons is simple enough:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
super.onKeyUp(keyCode, event);
if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
// Do something if currentVolume is low enough
// return true;
}
// Check if Up is pushed too
return false;
}
And a Toast is pretty easy too:
Toast.makeText(context, "Message", Toast.LENGTH_LONG).show();
If you ever want your app / service to do more with the current volume, you may realize that this isn't as straight forward as it sounds...
This method tells the system which audio stream to adjust with the volume buttons while your app is active:
setVolumeControlStream(AudioManager.STREAM_MUSIC);
Read the documentation on this and you get a glimpse of how unpredictable tracking the volume yourself can be. Here's a question on the same subject: How can I manage audio volumes sanely in my Android app?