Search code examples
androidbroadcastreceiverhttp-live-streaming

How to pause and play audio stream when receiveing a phone call


I stream audio in my app. It's done but when I receive a call I should pause the stream until the call is finished, and then play the stream again. Is it possible to pause and play the stream while receiving a call in android?


Solution

  • You can use the PhoneStateListener to see the status of the phone, and pause your audio stream when the phone is in use. The android reference shows you the callbacks you can use, and this example shows you how to use it. Note that you'll need to add a permission to your manifest:

    <uses-permission android:name="android.permission.READ_PHONE_STATE">