FileDocCategorySizeDatePackage
JniLibTest.javaAPI DocAndroid 5.1 API2028Thu Mar 12 22:22:42 GMT 2015android.core

JniLibTest

public class JniLibTest extends TestCase

Fields Summary
Constructors Summary
Methods Summary
private static native intnativeStaticThing(float f)

private native voidnativeThing(int val)

protected voidsetUp()

        super.setUp();
        /*
         * This causes the native shared library to be loaded when the
         * class is first used.  The library is only loaded once, even if
         * multiple classes include this line.
         *
         * The library must be in java.library.path, which is derived from
         * LD_LIBRARY_PATH.  The actual library name searched for will be
         * "libjni_lib_test.so" under Linux, but may be different on other
         * platforms.
         */
        try {
            System.loadLibrary("jni_lib_test");
        } catch (UnsatisfiedLinkError ule) {
            Log.e("JniLibTest", "WARNING: Could not load jni_lib_test natives");
        }
    
public voidtestNativeCall()

        Log.i("JniLibTest", "JNI search path is "
                + System.getProperty("java.library.path"));
        Log.i("JniLibTest", "'jni_lib_test' becomes '"
                + System.mapLibraryName("jni_lib_test") + "'");

        int result = nativeStaticThing(1234.5f);
        nativeThing(result);