java.lang.UnsupportedOperationException: AudioEffect: invalid parameter operation exception on Android Nougat (7.0)

五迷三道 提交于 2019-11-29 12:43:49

I don't exactly know why it is throwing error on Nougat but one possible reason is that there might be no preset available. So to be sure you may check first whether any preset is available or not using getNumberOfPresets().

If you run on custom ROM (but also other legacy rom that use a system Equalizer), you must disable system equalizer for your audio session id:

    private  void unbindSystemEqualizer(int audioSessionId) {
    Intent intent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, audioSessionId);
    intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, mContext.getPackageName());
    mContext.sendBroadcast(intent);
}

Have sure that your custom Equalizer is enabled and a settings was available before launching broadcast intent This work for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!