I have a service using 2 types mediaPlayback
and microphone
and declared like this in AndroidManifest:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<service
android:name=".player.SomeService"
android:enabled="true"
android:label="MusicAndMicroService"
android:exported="true"
android:foregroundServiceType="mediaPlayback|microphone">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService"/>
</intent-filter>
</service>
On When targetSdkVerion 34 and on Android 14, we also need pass service type constant when calling startForeground()
.
Currently I call like this:
ServiceCompat.startForeground(service, R.id.exampleNotiId, notificationBuilder.build(),
ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK or ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE)
As a result it will do a bitwise and my value pass to startForeground
will be wrong.
Anyone have solution for this when update targetsdkversion to 34?
Thank you for your help