Reputation: 6867
I'm using the following function (in Activity) to detect volume buttons clicks:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP){
if(mAudioManager != null){
int curVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
Intent intent = new Intent();
intent.setAction(VerticalSeekBar.ACTION_VOLUME_CHANGED);
intent.putExtra(VerticalSeekBar.ARGUMENT_VOLUME_VALUE,curVolume);
sendBroadcast(intent);
return true;
}
}
return super.onKeyDown(keyCode, event);
}
Thing is I have popupwindow which represents volume bar as Vertical seek bar in it's view. when the popupwindow is shown the onKeyDown in my activity is not being called untill I dimissed the popupwindow.
any suggestion how to solve this issue? is there another way to detect volume buttons clicks? thanks very much for the help
Upvotes: 1
Views: 984
Reputation: 366
Try set focusable false for your PopupWindow class.
mMyPopupWindow.setFocusable(false);
Upvotes: 4
Reputation: 3415
Not sure how you are actually using that Popup but if you use a Dialog instead you have access to the onKeyDown(); for the Dialog.
Upvotes: 0