android - In JNI, setting and getting elements from jobjectArray -
jstring ret_str = (*env)->newstringutf(env, output); (*env)->setobjectarrayelement(env,result,1,ret_str); jint bit_count = 5; (*env)->setobjectarrayelement(env,result,0,(jobject)bit_count);
the last line gives error fatal error.
here output
char*
, result
jobjectarray
.
all need add strings,ints,floats etc... jobjectarray , want return jobjectarray.
when adding jstring their's no error other primitive type throwing error.
you cannot cast jint jobject in java. c has no idea how promote data type. need find java.lang.integer class in jni , construct jint argument integer jobject.
here code, go , review documentation , preform needed error checking.
jclass integer_class = (*env)->findclass(env, "java/lang/integer"); jmethodid = integer_init = (*env)->getmethodid( env, integer_class, "<init>", "(i)v"); integer_object = (*env)->newobject( env, integer_class, integer_init, bit_count);
Comments
Post a Comment