Class NativeLoader
java.lang.Object
com.facebook.soloader.nativeloader.NativeLoader
Facade to load native libraries for android
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetLibraryPath(String shortName) Get the path of a loaded shared library.static intGet the version of the loader used.static voidinit(NativeLoaderDelegate delegate) Initializes native code loading for this app.static voidinitIfUninitialized(NativeLoaderDelegate delegate) Perform an initialization only ifNativeLoaderhas not already been initialized.static booleanDetermine whetherNativeLoaderhas already been initialized.static booleanloadLibrary(String shortName) static booleanloadLibrary(String shortName, int flags) Load a shared library, initializing any JNI binding it contains.
-
Method Details
-
loadLibrary
-
loadLibrary
Load a shared library, initializing any JNI binding it contains. Depending upon underlying loader, behavior can be customized based on passed in flag- Parameters:
shortName- Name of library to find, without "lib" prefix or ".so" suffixflags- 0 for default behavior, otherwise NativeLoaderDelegate defines other behaviors.- Returns:
- Whether the library was loaded as a result of this call (true), or was already loaded through a previous call (false).
-
getLibraryPath
Get the path of a loaded shared library.- Parameters:
shortName- Name of library to find, without "lib" prefix or ".so" suffix- Returns:
- The path for the loaded library, null otherwise.
- Throws:
IOException- IOException
-
getSoSourcesVersion
public static int getSoSourcesVersion()Get the version of the loader used.- Returns:
- The version number for the loader.
-
init
Initializes native code loading for this app. Should be called only once, before any calls toloadLibrary(String).- Parameters:
delegate- Delegate to use for allloadLibrarycalls.
-
isInitialized
public static boolean isInitialized()Determine whetherNativeLoaderhas already been initialized. This method should not normally be used, because initialization should be performed only once during app startup. However, libraries that want to provide a default initialization forNativeLoaderto hide its existence from the app can use this method to avoid re-initializing.- Returns:
- True if
init(NativeLoaderDelegate)has been called.
-
initIfUninitialized
Perform an initialization only ifNativeLoaderhas not already been initialized. This protects against race conditions where isInitialized and init are called by multiple threads and both threads end up trying to perform an initialization- Parameters:
delegate- the NativeLoaderDelegate
-