.Net Maui Barcode Scanner is causing app to navigate backwards

52 Views Asked by At

WHen running on windows and android, if im using a shell app when the physical barcode scanner sends the enter key the app is navigating backwards.

If i convert the app to not be a shell app it does not navigate backwards but when i scan on android i get an error about not able to set input from inactive input connector.

The app im using was converted from xamarin, but this problem exists even when spinning up brand new app.

On android im using the global key up in main activity and storing that barcode for different views to use. If shell app this method executes fine but eventually the app just navigates backwards. If not shell this method is not even called.

public override bool OnKeyUp([GeneratedEnum] Keycode keyCode, KeyEvent e)
 {
     if (keyCode == Keycode.Enter || keyCode == Keycode.NumpadEnter || keyCode == Keycode.ButtonL1)
     {
         Console.WriteLine($"OnKeyUp:: KeyCode: {keyCode.ToString()}, IsPrintKey: {e.IsPrintingKey}, DisplayLabel: '{e.DisplayLabel}'");
         App.SubmitKeyEntry(keyCode.ToString());
     }
     else if (e.IsPrintingKey)
     {
         Console.WriteLine($"OnKeyUp:: KeyCode: {keyCode.ToString()}, IsPrintKey: {e.IsPrintingKey}, DisplayLabel: '{e.DisplayLabel}'");
         App.AddKeyEntry(e.DisplayLabel.ToString());
     }
     else if (e.Action == KeyEventActions.Multiple)
     {
         Console.WriteLine($"OnKeyUp:: KeyCode: {keyCode.ToString()}, IsPrintKey: {e.IsPrintingKey}, DisplayLabel: '{e.DisplayLabel}', Action: {e.Action.ToString()}, Characters: '{e.Characters}'");
         App.AddKeyEntry(e.Characters);
     }
 
     return base.OnKeyUp(keyCode, e);
 }

Does anyone have a working example using a physical barcode scanner for android and windows. This app will never use the camera for scanning.

Ive tried adjusting focus manually but the app still navigates backwards.

0

There are 0 best solutions below