Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FileDescriptor for USB Accessory gets closed

I use a service to open connection to USB Accessory. I use an input stream that is bind to the FileDescriptor I get from UsbManager's openAccessory() method. Everything works fine as long as I don't start a new activity. For some reason when I start a new activity I get IOException (File descriptor closed). Any ideas why this is happening? I wan't it to work so that the input stream stays connected across activities.

like image 397
Frank X Avatar asked Apr 28 '26 20:04

Frank X


1 Answers

You must put your usb connection in a Service (not a bind service but foreground or background) and communicate the data received with a broadcast receiver.

like image 96
Pam Avatar answered Apr 30 '26 09:04

Pam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!