altera2015 / usbserial

Flutter Android USB Serial plugin
BSD 3-Clause "New" or "Revised" License
119 stars 83 forks source link

Where to put intent-filter, under <activity? #109

Closed HamiguaLu closed 2 months ago

HamiguaLu commented 3 months ago

Hi Just wonder where I should put the below line in my Androidmanifest.xm

<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
    android:resource="@xml/device_filter" />

Thanks in advance

tommie commented 2 months ago

It goes as a sibling to the intent filter.

Here's an example: https://gist.github.com/tommie/568d11fecc3ab5b8fd20de39d4407389

rockerer commented 2 months ago

Taken directly from the documentation

<manifest ...>
    <uses-feature android:name="android.hardware.usb.host" />
    <uses-sdk android:minSdkVersion="12" />
    ...
    <application>
        <activity ...>
            ...
            <intent-filter>
                <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
            </intent-filter>

            <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
                android:resource="@xml/device_filter" />
        </activity>
    </application>
</manifest>