Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Override volume up/down buttons

$
0
0

Hi all, I want to override the volume up/down buttons so I can trigger a barcode scan (I'm using a Vuzix M100 - this has very limited input controls, just volume up/down, power and select/back).

I can detect the up/down buttons with the following code:

public override bool OnKeyUp(Keycode keyCode, KeyEvent e)
        {
            if (keyCode == Android.Views.Keycode.VolumeDown)
            {
                if (ItemsToScan > 0)
                {
                    DoScan();
                }
                return true;
            }

            if (keyCode == Android.Views.Keycode.VolumeUp)
            {
                ItemsToScan = 4;
                this.RunOnUiThread(() =>
                {
                    txtScanned.Text += string.Format("Reset - {0} scans remaining.\n", ItemsToScan);
                }
                                );
                return true;
            }
            return base.OnKeyUp(keyCode, e);
        }

but the buttons still have their default effect of popping up the volume level on screen.

Is there a way to completely override their effect, so that I don't get the on-screen volume display? I thought returning true should indicate that I've handled the event.

Thanks,

James


Viewing all articles
Browse latest Browse all 204402

Trending Articles