Skip to content

[Android] Does not work when targetSdkVersion is set to 31+ #8

@Colton127

Description

@Colton127

To replicate: Open example, change targetSdkVersion to 31 (or 32) in build.gradle, make the necessary changes in AndroidManifest, and build.

You will have to make these minor adjustments in AndroidManifest
Under "<activity
android:exported="true"

And make this the intent-filter

     <receiver
            android:name="flutter.moum.headset_event.HeadsetBroadcastReceiver"
            android:exported="true" >
            <intent-filter>
                <action android:name="android.intent.action.HEADSET_PLUG" />
                <action android:name="android.intent.action.MEDIA_BUTTON" />
            </intent-filter>
        </receiver>

This will allow you to successfully build the release onto your device. However, the listener does not work at all. It simply does not respond to bluetooth connect/disconnect events. Setting TargetSdkVersion to 30, even while keeping the above manifest changes, fixes the problem entirely. This is on an Android 12 device.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions