Android USB Host mode service - Start based on USB_DEVICE_ATTACHED

后端 未结 3 1113
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-10 03:21

I want to write a service in Android which starts based on USB_DEVICE_ATTACHED intent. So, basically my service should start when a specific USB Device(FT232C - VID:PID 0403:601

3条回答
  •  醉话见心
    2021-02-10 04:13

    I believe the main problem is the number base for the vendor and product id's. The format in the device filter xml should be decimal, so vendor-id="1025" and product-id="24592".

    Aside from that, it absolutely should be USB_DEVICE_ATTACHED, rather than UMS_CONNECTED (the latter is not USB host mode at all).

    I don't have the authoritative answer as to whether a service could receive a broadcast intent, or whether you have to use an activity for that, but it seems like Wayne Uroda has good experience with this question.

提交回复
热议问题