Forum Xamarin.Forms

App crashing when setting the UsbManager and no USB device is connected

Hello,

I am developping an application using a USB Smartcard reader.

When no device is connected, the following line makes the app crash.
mManager = (UsbManager)Android.App.Application.Context.GetSystemService(Context.UsbService);

Should I check if a device is connected before?
If yes, how?

Best regards.
Claudy

Tagged:

Answers

  • HarshitaHarshita INMember ✭✭✭✭

    use try catch block for exceptions.and then see what exact exception your are getting.

Sign In or Register to comment.