Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8093549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:31:33+00:00 2026-06-05T20:31:33+00:00

I am developing an application, in which i need to capture the audio being

  • 0

I am developing an application, in which i need to capture the audio being played. So i implemented OnAudioFocusChangeListener in my activity to listen for any audio changes. But the listener is not getting called when music is played or paused. Below is my code

public class AudioManagerExample extends Activity implements OnAudioFocusChangeListener{
  AudioReceiver adreceiver;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    AudioManager am =   (AudioManager) getSystemService(AUDIO_SERVICE);

}

@Override
public void onAudioFocusChange(int focusChange) {
    Log.d("AudioManager", "Inside on audio focus change");
}

}

Where am i wrong? Is there any alternative way to do this?

Thanks

Pushpa

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:31:34+00:00Added an answer on June 5, 2026 at 8:31 pm

    You forgot to include

     am.requestAudioFocus(this,AudioManager.STREAM_MUSIC,AudioManager.AUDIOFOCUS_GAIN);
    

    Change your code to

    AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE);
    am.requestAudioFocus(this,AudioManager.STREAM_MUSIC,AudioManager.AUDIOFOCUS_GAIN);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing application which need access to user's facebook account. It is working, but
I am developing an application in which I need to extract the audio from
I am developing an application in which I need to get the list of
I am developing an android application in which I need to launch an Fragment
I am developing an iPad application in which I need a table view (
I am developing an iPhone application in which i need to connect with twitter.
I am developing a VB application in which i need to know the native
I am developing a application which uses location services. I need to debug the
I am developing an application, in which i need 3 keyboard which should looks
I am developing an iPhone application, in which i need to write characters scan

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.