Closed realrk95 closed 11 months ago
I couldn't find the functionality in the API reference.
Hi, maybe you can just listen to the USB events and get a status from there :
UsbSerial.usbEventStream.listen((UsbEvent msg) async {
if (msg.event == UsbEvent.ACTION_USB_ATTACHED) {
// Do something if usb attached
} else if (msg.event == UsbEvent.ACTION_USB_DETACHED) {
// Do something else if usb detached
}
});
If you declared your usb device(s) in android manifest, you will receive events for them...
Thanks, this is kind of what I was looking for. What about checking permissions or getting permissions in case the user has denied it? Is there any library which exposed that API?
Great ! Yes I use https://pub.dev/packages/permission_handler to ask the user about permissions...
Thanks m8, this works.
Closing since fixed.
Hi,
I'm trying to create a stream for listening to the USB status (permission allowed/denied, OTG available or not, etc.). Is there any functionality built into this library to check for the same?
here is the sample pseudo code:
Is this functionality like statusStream or USBStatus available in this library for easy detection of sudden changes from the user (user suddenly disables OTG, OTG is not available on this device etc.)?