Hi @mithil kumar
Thanks for reaching out to Microsoft Q&A.
The microphone issue when the app goes into the background with Azure Communication Services (ACS) on Android. This happens often because of Android's background execution limits, which can restrict mic access.
Android limits background access to the microphone. A Foreground Service ensures continuous audio capture during calls.
Declare Foreground Service in AndroidManifest.xml,
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<service
android:name=".CallForegroundService"
android:foregroundServiceType="microphone|mediaProjection"
android:exported="false"/>
Create the Foreground Service (CallForegroundService.kt
),
class CallForegroundService : Service() {
override fun onCreate() {
super.onCreate()
startForegroundService()
}
private fun startForegroundService() {
val notification = NotificationCompat.Builder(this, "CALL_CHANNEL_ID")
.setContentTitle("Call in Progress")
.setContentText("Your call is active")
.setSmallIcon(R.drawable.ic_call)
.setOngoing(true)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.build()
startForeground(1, notification)
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
return START_STICKY
}
override fun onBind(intent: Intent?): IBinder? {
return null
}
override fun onDestroy() {
super.onDestroy()
}
}
Start the Foreground Service Before Accepting a Call,
val serviceIntent = Intent(this, CallForegroundService::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(serviceIntent)
} else {
startService(serviceIntent)
}
ref: Known Issues with ACS
Best Practices for ACS
Troubleshooting Microphone Issues
If the answer is helpful, please click Accept Answer and kindly upvote it so that other people who faces similar issue may get benefitted from it.
Please let us know if you need further assistance.