1

I have an app and an accessory and I'm having issues with the USB_ACCESSORY_ATTATCHED intent not being fired when the device is booted and the accessory is already plugged in. The workflow works great when the device is on and the user plugs in the accessory so I'm positive I set the intent filter up correctly.

My manifest

<activity
android:name=".Activity"
android:launchMode="singleTask">
<intent-filter>
    <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
</intent-filter>

<meta-data
    android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
    android:resource="@xml/accessory_filter" />
</activity>

On the accessory side, I see that the phone gets put in accessory mode before it's even booted and I'm guessing that is the issue. Unfortunately prompting for usb permissions isn't feasible as the user may not have access to the androids ui and that function only gives temporary access.

Erik
  • 493
  • 1
  • 7
  • 18
  • I am having a similar problem. Did you ever solve this? – Mark Lummus Apr 16 '19 at 09:50
  • I unfortunately never did. – Erik Apr 17 '19 at 16:51
  • take a look at this SO question: https://stackoverflow.com/questions/50682808/connect-android-usb-accessory-when-screen-is-off – Mark Lummus Apr 18 '19 at 19:08
  • 1
    that question helped me figure this out. I believe the problem in my situation is making sure to open the accessory and send the right initialization commands to the accessory within 10 seconds of when it is attached (a timeout defined in the Android USB source code). – Mark Lummus Apr 18 '19 at 19:09

0 Answers0