This article from: http://codingnow.cn/cocos2d-x/992.html
Abstr:This article mainly implements two functions: (1) obtain the packagename of the application through the android sdk api, and then pass it to the C ++ layer function. (2) Call the Java-layer function of Android through the C ++ function. A dialog box is displayed, and click the button to exit the program. 1. First, let's take a simple look at the knowledge of JNI. In this article, I have implemented how to call C ++ functions on the android Java layer. To use JNI, you must...
This article mainly implements two functions:
(1) obtain the packagename of the application through the android sdk api, and then pass it to the C ++ layer function.
(2) Call the Java-layer function of Android through the C ++ function. A dialog box is displayed, and click the button to exit the program.
1. First, let's take a simple look at the knowledge of JNI. In this article, I have implemented how to call C ++ functions on the android Java layer. To use JNI, the header file must be included. Android uses ndk to compile C/C ++. Here, JNI. h file is located in: \ android-ndk-r8b \ platforms \ Android-14 \ arch-Arm \ USR \ include \ JNI. h. This file defines all JNI-related data types and interfaces. The following is a code snippet:
| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
# include <inttypes.h> /* C99 */typedefuint8_t jboolean; /* unsigned 8 bits */typedefint8_t jbyte; /* signed 8 bits */typedefuint16_t jchar; /* unsigned 16 bits */ |