![]() |
VOOZH | about |
Audio focus is important to manage while building an application that plays an audio file within the application. With the help of this, we can again play the audio file from where it was paused originally. In this article, we will take a look at How to manage audio focus in android applications using Jetpack Compose.
To create a new project in the Android Studio, please refer to How to Create a new Project in Android Studio with Jetpack Compose.
Navigate to app > res, now right click on the res folder and select New > Android resource directory, specify name and type as raw and select Ok. Now, right click on the raw folder and paste your music file.
Go to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.
MainActivity.kt: