Any idea why this code doesnt work? I am trying to update a TextView of the system volume when the volume up/down key is pressed.
Racking my brain on this one, thanks guys
Code:
TextView sysVol = (TextView)findViewById(R.id.systemVolume);
sysVol.setOnKeyListener(new OnKeyListener()
{
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
//system volume
int curVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
int i = curVolume * 4;
String aString = Integer.toString(i);
TextView sysVol = (TextView)findViewById(R.id.systemVolume);
sysVol.setText(aString);
sysVol.invalidate();
return true;
}
return false;
}
});
Racking my brain on this one, thanks guys
We all have those moments 