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 strcpy
or 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
Post a Comment