Wednesday, February 12, 2014

Android, how to see the definition of native methods


            
JNI to call C / C + + function I know, so do not copy what JNI principle like a lot of trouble you, but I still welcome the top.

I was recently looking at Android source code, I want to know how to quickly find the definition of native method in which, source insight I used.

Thank you-_-.
Reply:
Not quite understand what it meant you want! ?
Reply:
Quote = reference to a floor reply:]
Not quite understand what it meant you want! ?
[/ Quote] For example, I now look to achieve SystemProperties class Andrews in his source as follows:

-_-| Source copy is not on, do not know how this class calls the native method, but only a statement of the native method, using go to definition is not effective, because it is the c / c + + code is compiled into a dynamic library reasons for it, then I see how this native method defined it?


Reply:
No source files, look unlikely to achieve it
Reply:
The reply was deleted at the moderator 2012-06-27 08:27:09

Reply:
reference to the third floor of the reply:
no source files, look unlikely to achieve it
android is not open source it? He should just compiled into a dynamic library, but the code should still ah
Reply:
Open source, it is impossible to achieve the core part does not let anyone see ah.
Reply:
The class name that contains native functions, the entire project was found in the file name, file name can not find it through all of C or C + + file content, if we can not find, and that is no. . . . .
Reply:
Have c or c + + source files for the job
Reply:
native methods are not directly see the source code.
Reply:
I have to say that a function to give you examples given it

Reply:
android source code using native methods is not what you think, be able to view its specific definition. In fact, it is a specific definition (eg lib / hello-jni.c or. Cpp file) in libraries. For example, in package \ app under a ServiceMenu, which there are corresponding cpp file, use native method function is modified in the implementation of cpp file, for example:..
Define a hello-jni.c file, which is defined inside a function: Java_cn_com_ndk_Main_stringFromJNI (JNIEnv * env, jobject thiz) {}, then the corresponding native way we define that: public native string stringFromJNI (); then get Java_cn_com_ndk_Main_stringFromJNI ( JNIEnv * env, jobject thiz) function of the corresponding string. This is what I see in the above document, want to help, thank you.

No comments:

Post a Comment