USB Accessory not communicating after restart

↘锁芯ラ 提交于 2019-12-06 06:07:15

in UsbManager and IntentFilter you use ACTION_USB_ACCESSORY_DETACHED and ACTION_USB_ACCESSORY_ATTACHED events that are triggered when plugging or unplugging the device.

if these events /actions occur the code is executed and the app works

( https://developer.android.com/reference/android/hardware/usb/UsbManager.html )

the problem is now that when the app is started at reboot these events /actions are not triggered and so the code that is linked to them will not be executed

it is not easy to circumvent this because an application gets an instance of the UsbAccessory class only via the ACTION_USB_ACCESSORY_ATTACHED intent :

An instance of this class is sent to the application via the ACTION_USB_ACCESSORY_ATTACHED Intent. The application can then call openAccessory(UsbAccessory) to open a file descriptor for reading and writing data to and from the accessory.

source : https://developer.android.com/reference/android/hardware/usb/UsbAccessory.html

it is not possible for the app to use a class ( the accessory ) if it has no instance of it ...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!