我有两个按钮,一个打开手机的默认均衡器,一个打开我的应用程序特定的音频效果(混响,BassBoost和虚拟器)。每当默认均衡器打开,并且我打开特定于应用程序的音频效果活动时,应用程序崩溃。
错误的Logcat附在下面。
com.widefide.musicplayer/com.widefide.musicplayer.EqualizerActivity}: java.lang.UnsupportedOperationException: AudioEffect: invalid parameter operation
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.UnsupportedOperationException: AudioEffect: invalid parameter operation
at android.media.audiofx.AudioEffect.checkStatus(AudioEffect.java:1273)
at android.media.audiofx.Virtualizer.setStrength(Virtualizer.java:153)
at com.widefide.musicplayer.MusicService.setVirtualizerStrength(MusicService.java:571)
at com.widefide.musicplayer.EqualizerActivity.setVirtualizerStrength(EqualizerActivity.java:65)
at com.widefide.musicplayer.Fragments.EQ.FXFragment.onProgressChanged(FXFragment.java:183)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:93)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:1303)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:1315)
at android.widget.ProgressBar.setMax(ProgressBar.java:1466)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:339)
at com.widefide.musicplayer.Fragments.EQ.FXFragment.onActivityCreated(FXFragment.java:87)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1983)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1092)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1234)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2046)
at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:174)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:598)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237)
at android.app.Activity.performStart(Activity.java:6268)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
现在,当我通过Intent打开audioEffects活动时,我想以编程方式关闭Phone的均衡器。代码将遵循如下:
// Before opening FX, turn Equalizer OFF
.. EQ OFF code here ...
// FX
Intent intent = new Intent(getContext(), FX.class);
startActivity(intent);