android - How to fill a C++ char[] with an JNI jobjectarray (Java String[])? -


i think question says all. work android ndk. cannot include std, no use of vectors please, plain , simple c++. here's have far:

 // filepaths = jobjectarray = java string[] int elementcount = env->getarraylength(filepaths);  // should end being char[] filepaths in char *cppfilepaths[elementcount];  (int = 0; < elementcount; i++) {   jstring jfilepath = (jstring) (env->getobjectarrayelement(filepaths, i));   const char *cppfilepath = env->getstringutfchars(jfilepath, 0);    // not work!   cppfilepaths[i] = cppfilepath;    env->releasestringutfchars(jfilepath, cppfilepath);   env->deletelocalref(jfilepath); } 

with code i'll end cppfilepaths containing elementcount entries of last string in filepaths.

i searched lot , found out strcpyor memcpy, nothing worked far.

this works now. have no idea, if it's okay directly use result of getstringutfchars, until no errors...

 const char *cppfilepaths[elementcount] = {};  (int = 0; < elementcount; i++) {   jstring jfilepath = (jstring) (env->getobjectarrayelement(filepaths, i));   cppfilepaths[i] = env->getstringutfchars(jfilepath, 0);   env->deletelocalref(jfilepath); } 

Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -