Class CLLibraryLoader


  • public class CLLibraryLoader
    extends Object
    The library loader class is a class that provides static methods to register native libraries that will be loaded on request.

    The class will load `gnustl_shared` first, then the registered libraries in order of registration and the the castLabs player libraries.

    In addition to library names, you can also register CLLibraryLoader.PostLoadAction instances. Registered implementations of this interface will be executed once after libraries are loaded.

    • Field Detail

      • ENABLED

        public static boolean ENABLED
        The library loader can be disabled. This is useful for unit tests where the native libraries can not be loaded
    • Method Detail

      • register

        public static void register​(@NonNull
                                    String name)
        Register a library that needs to be loaded. NOTE that the name is the base name of the library without the "lib" prefix and without the ".so" suffix! For example, say you want to load libgnustl_shared.so that is distributed with your app. In this case you need to register "gnustl_shared" with this method
        Parameters:
        name - the library base name, i.e. "gnustl_shared"
      • register

        public static void register​(@NonNull
                                    CLLibraryLoader.PostLoadAction postLoadAction)
        Register a new post load action that will be executed by the loader after the native libraries are loaded.
        Parameters:
        postLoadAction - the post load action
        Throws:
        IllegalStateException - in case the libraries are already loaded
      • load

        public static void load()
        Call this method to load the registered native libraries and execute the post load actions.

        *NOTE* that you usually do *NOT* need to call this method explicitly. The framework will take care of library loading for you.