I have written below code in onCreate method of activity.
MusicPlayer.getEqualizerHelper().getCurrentEqualizer().usePreset((short) 0); --- line no 1
short numberFrequencyBands = MusicPlayer.getEqualizerHelper().getCurrentEqualizer().getNumberOfBands();--- line no 2
final short lowerEqualizerBandLevel = MusicPlayer.getEqualizerHelper().getCurrentEqualizer().getBandLevelRange()[0];--- line no 3
and it works fine in all android o.s below nougat. When I install my app on nougat device it throws exception on line no 1. Please suggest me where is the problem and solution for it. Thanks in advance
FATAL EXCEPTION: main Process: com.ag.musicplayer, PID: 15039 java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.ag.musicplayer/com.ag.musicplayer.activity.EqualizerActivity}: java.lang.UnsupportedOperationException: AudioEffect: invalid parameter operation at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: java.lang.UnsupportedOperationException: AudioEffect: invalid parameter operation at android.media.audiofx.AudioEffect.checkStatus(AudioEffect.java:1273) at android.media.audiofx.Equalizer.usePreset(Equalizer.java:335) at com.ag.musicplayer.activity.EqualizerActivity.onCreate(EqualizerActivity.java:287) at android.app.Activity.performCreate(Activity.java:6664) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)