I have a custom Android device that has additional hardware buttons. Those buttons are used to trigger a barcode scanner on the device.
I am trying to trigger the keypress from code so far i tried:
MainActivity.Instance.DispatchKeyEvent ( new Android.Views.KeyEvent(
Android.Views.KeyEventActions.Down,
Android.Views.Keycode.Eisu
));
Eisu
is 211 which is my button's keycode.
But this gives me nothing. Has anyone managed this?
Edit
I also tried with instrumentation:
await Task.Run (delegate {
Instrumentation inst = new Instrumentation();
inst.SendKeyDownUpSync (Android.Views.Keycode.Eisu);
});
No luck on this... I am guessing that the events get dispatched but somehow no context catches them.
This is called from DependencyService
in xamarin.forms
, could it be a problem?