Closed mening12001 closed 1 day ago
Hello, @mening12001
To start the foreground service on android14, foregroundServiceType
and permission
are required.
https://developer.android.com/about/versions/14/changes/fgs-types-required#microphone
Therefore, you must be declared as follows in the Manifest:
<!-- required -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!-- foregroundServiceType: microphone -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!-- Warning: Do not change service name. -->
<service
android:name="com.pravera.flutter_foreground_task.service.ForegroundService"
android:foregroundServiceType="microphone"
android:exported="false" />
Here is a demo app that uses this permission.
https://github.com/Dev-hwang/flutter_foreground_task_example/tree/main/record_service
Hello, Thank you for the response.
There is an issue when setting the type of the service to "microphone" on Android 14. The android.permission.FOREGROUND_SERVICE_MICROPHONE must be acquired.
Please consider solving this issue by including the permission request. Thank you!