Search code examples
androidandroid-intentaccessory

Android accessory displays splash screen instead of launching app


I'm developing an Android app to interface with a custom accessory, using a Moto X 1st-gen and a Galaxy S5 for testing. On both of these phones, when the accessory is connected, instead of prompting the user to launch the app, it simply displays a gray modal with the accessory company's logo. The strange thing is that if I have multiple apps installed with this accessory filter, the launch-app prompt does pop up, and if I select my app and launch it through the prompt, it works as expected. If I select 'always launch' and then uninstall the other app, it works as expected. But if I update the app, the problem resurfaces.

I can't seem to find any other instances of this problem occurring. I've tried changing which Activity the intent-filter is tied to; no luck.

I've configured the AndroidManifest like so:

<uses-sdk
    android:minSdkVersion="17"
    android:targetSdkVersion="19" />

<uses-feature android:name="android.hardware.usb.accessory" />

...

<application>

  <uses-library android:name="com.android.future.usb.accessory" />

  ...

  <activity
      android:name=".activity.AccessoryActivity"
      android:label="@string/app_name"
      android:launchMode="singleTask"
      android:screenOrientation="portrait"
      >
      <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>
</application>

And have my accessory_filter set up like so:

<resources>
    <usb-accessory manufacturer="My-Manufacturer" model="My-Model" version="1.0"/>
</resources>

Solution

  • It seems that this behavior was occurring because I was using a large PNG (671x725) in the drawable folder as the app icon. When I got around to creating individual icons at the appropriate dpi sizes, the problem vanished. I have no clue why icon size would have any bearing whatsoever on the ability of the OS to launch an app on accessory connect, but there you go.