Search code examples
androidequalizer

How to open the built in Equalizer programmatically in Android?


I have seen many apps opening systems in built Equalizer (google play music, Spotify, Samsung stock music player). Directly, without having to write their own from scratch. How do these apps do that? I couldn't find a solution.

} else if (id == R.id.action_fx) {
        Intent intent = new Intent();
        intent.setAction("android.media.action.DISPLAY_AUDIO_EFFECT_CONTROL_PANEL");
        if ((intent.resolveActivity(getPackageManager()) != null)) {
            startActivity(intent);
        } else {
            Intent intent11 = new Intent(MainActivity.this, Help.class);
            intent11.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            startActivity(intent11);
            // No equalizer found :(
        }
        return true;

Solution

  • The following should work to start the default equalizer Activity:

    Intent intent = new Intent(AudioEffect
        .ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
    
    if ((intent.resolveActivity(getPackageManager()) != null)) {
        startActivityForResult(intent, REQUEST_EQ);
    } else {
        // No equalizer found :(
    }
    

    Spotify does the same basically, haven't checked the others.

    The necessity of startActivityForResult() is explained in the docs:

    The intent carries a number of extras used by the player application to communicate necessary pieces of information to the control panel application.

    The calling application must use the android.app.Activity#startActivityForResult(Intent, int) method to launch the control panel so that its package name is indicated and used by the control panel application to keep track of changes for this particular application.