In this case, should also be getNativeString(). In our example, we declared the native method getNativeString(). : This name should be the same as the one you declare inside the connecting. : The package name where the previously defined resides in. In our example, this would be MainActivity, since that's the Java class that will use this function. : The connecting Java class this function is tied to. JNICALL: Contains compiler directives required to ensure the function is treated with the proper JNI calling convention. For example, in the method you just wrote above, you are returning a jstring, which is the native equivalent of String in Java. : Return type of the JNI method, usually a native version of a Java type. Your MainActivity class should look like the following:Ĭontains compiler directives required to ensure the function is exported properly. This will link the native module with name helloWorldJni with the MainActivity class at runtime, which we will write later. In a static block inside the class (usually at the top, by convention), add the line System.loadLibrary("helloWorldJni"). In MainActivity.java, for the sake of simplicity, remove any override methods except for onCreate(Bundle).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |