2

I want to make the users default equalizer work with my app, but I can't seem to get my app audio session to connect with the equalizer even though I am passing it my Audio Session ID etc.

Here is my code:

          Intent i = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
            i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, MusicPlayerService.getMPSessionId());
            startActivityForResult(i, 11113);

I am using the code above to launch the user's default Equalizer.

    @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {

        System.out.println("RESULT_OK");

        Equalizer equalizer = new Equalizer(0,MusicPlayerService.getMPSessionId());
        equalizer.setEnabled(true);

        return;
    }

}

And then I am using the code above to apply enable and apply it. What am I doing wrong here? I have a few apps on my phone that use the stock Equalizer and they all work fine.

If somebody could help me out, that would be highly appreciated, thanks.

Jack
  • 2,043
  • 7
  • 40
  • 69

1 Answers1

0
mAudioSession = mp.getAudioSessionId();

try {

    final Intent effects = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);

    effects.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, this.getPackageName());

    effects.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, mAudioSession);

    startActivityForResult(effects, 0);

} catch (Exception e) {

    // ignored. Whee!

}

First add this code, int mAudioSession = 0; , above mAudioSession line, if that makes sense. This code should work, tested it and it works fine. I think what youre missing is, Package name, Also you don't needequalizer.enabled` true, it won't do anything at all, I think that's for making you're own equalizer. Also I think you can use equalizer.setenabled(true) etc.