kechankrisna / flutter_usb_printer

GNU General Public License v3.0
7 stars 52 forks source link

Null Exception Handling #25

Closed Jerinji2016 closed 4 months ago

Jerinji2016 commented 1 year ago

Changes

1. Changed USBPrinterAdapter to singleton class.

Previously, USBPrinterAdapter().getInstance() worked same as constructor instantiating. Changed getInstance to static method and disposed the static instance on onDetachedFromEngine


2. mUsbDeviceReceiver receiver always receives null for usbDevice

Checked in Android 12 & 13, the intent extra for UsbManager.EXTRA_DEVICE is always null.
So, add the vendorId and productId to pendingIntent while requesting permissions. If UsbManager.EXTRA_DEVICE is null, then try to init usb device with vendorId and productId.


3. Moved pendingIntent from class scope to local scope

Since pending intent is only required when requesting permission, moved variable to local scope

Jerinji2016 commented 4 months ago

Any Updates on this @kechankrisna ?