0

I am trying to work with android Equalizer It works if my app has been started , but fails when another app uses equalizer

the app would crash whenever my app tries to access the equalizer library

Is there a way to know if equalizer is available other wise not to start the activity

here is the code I am trying

Equalizer eq = null;

if (eq != null) {
                eq.release();
            }



 try {
            eq = new Equalizer(0, 0);
     }
        catch (IllegalStateException e) {
                fail("Equalizer not initialized");
        }
        catch (IllegalArgumentException e) {

        } 
        catch (UnsupportedOperationException e) {

        }

but I still keep getting the error

java.lang.RuntimeException: java.lang.UnsupportedOperationException: Effect library not loaded

1234567
  • 2,226
  • 4
  • 24
  • 69

1 Answers1

0

you should call release() on your Equalizer object when you're finished with it. You can't have many instance of Equalizer object.

== UPDATE ==

In your catch block, the one causing issue, you could display a Toast and finish current activity :

catch (UnsupportedOperationException e) {
   //display a Toast
   finish();
}
HelloSadness
  • 945
  • 7
  • 17
  • it is done just to free up equalizer , there is no proper documentation from android for this – 1234567 Nov 13 '16 at 13:43
  • I would like to know any way to check if library is being used by other apps, then not start my activity – 1234567 Nov 13 '16 at 13:45
  • 1
    You could, when reaching catch block display a toast or inform the user the way you want that there is a pb and finish current activitty. – HelloSadness Nov 13 '16 at 13:53
  • I am trying to do exactly that , but even in the try catch it fails – 1234567 Nov 13 '16 at 13:54