This article gives the Android java pass int type array to C toadd the function of calling Logcat in C code
ANDROID.MK file Add the following content
Local_ldlibs + =-llog
Add the following in C code
#include <android/log.h>#define log_tag "System.out"#define logd (...) __android_log_print ( Android_log_debug, Log_tag, __va_args__)#define logi (...) __android_log_print (Android_log_info, Log_tag, __ VA_ARGS__)
Define C's macro defines the alias #define Log_tag "System.out" to "System.out" Alias Log_tag
#define Logi (...) __android_log_print (Android_log_info, Log_tag, __va_args__)
Alias to the __android_log_print function dead first two parameters precedence of the second parameter tag __va_args__ a fixed notation for variable parameters
Logi (...) Use the same as printf () when calling.
jnicall java_com_wuyudong_javapassdata_jni_arrelementsincrease (jnienv*env, Jobject clazz, Jintarray Jarray) {Jsize len= (*env)getarraylength (env, Jarray); Logd ( "length =%d", Len); //Jboolean iscopy; int* Arraypointer = (*env)getintarrayelements (env, Jarray, NULL); inti; for(i =0; i < Len; i++){ * (Arraypointer + i) + =Ten; } returnJarray;}
Get more knowledge of C language and algorithms, follow the public number: "Csuanfa"
Android calls Logcat in C code