File not found when running fmod in background and main application closed/swiped

Hi, unfortunately i have encountered yet another problem I can’t solve. I’m trying to keep fmod playing in the background even when the application is swiped from the user. I’m using a permanent notification with a foreground service to achieve that. Now, it seems to be working with files coming from the application bundle / assets folder, but not when reading files from the private folder (com.my.app/files)…

It’s erroring out with FMOD error 18 - File not found. (even though the file exists and can be read if I restart the app and play it while it’s open… Could anybody give me some hints as to what I’m doing wrong?

I was thinking that the context passed in is not valid anymore when the application is swiped, but then why would it keep working only with the assets folder file?

This is how I’m calling FMOD.init:

      for (String lib: BuildConfig.FMOD_LIBS)
      {
        System.loadLibrary(lib);
      }
      System.loadLibrary("my_native_lib_using_fmod");
      org.fmod.FMOD.init(context.getApplicationContext());

where context is a wrapper on the application context

correction for the code:
this is how I’m calling init (in a Service subclass)
org.fmod.FMOD.init(this)

solved. i was missing a jvm->AttachCurrentThread

1 Like

Thank you for sharing the solution!

1 Like