通过jni调用安卓相册,然后选中照片之后在<span style="“font-size:12px;line-height:1.5;”">onActivityResult中拿到照片路径名称,再调用coco2dx中函数加载精灵显示到屏幕上, <p class="“p1"”><span class="“Apple-tab-span”"> <span class="“Apple-tab-span”"> <span class="“Apple-tab-span”"> <span class="“s1"”>if (resultCode == <span class="“s2"”>RESULT_OK) {
Log.e("Himi", "这里是 onActivityResult,selectimage调用的");
Uri uriRecorder = data.getData();
Cursor cursor=this.getContentResolver().query(uriRecorder, null, null, null, null);
if (cursor != null && cursor.moveToNext()) {
strMediaPath = cursor.getString(cursor.getColumnIndex("_data"));
//Toast.makeText(this, strMediaPath, Toast.LENGTH_SHORT).show();
Log.e("Himi", "onActivityResult中,strMediaPath = " + strMediaPath);
addImageSprite(strMediaPath);
}
}
在addImageSprite中添加精灵到屏幕上
extern "C"
{
void Java_org_cocos2dx_testcpp_TestCpp_addImageSprite(JNIEnv* env, jobject thiz,jstring imagePath)
{
CCLog("这里是addImageSprite");
const char *temp = env->GetStringUTFChars(imagePath, NULL);
CCLog("temp路径是 %s",temp);
env->ReleaseStringUTFChars(imagePath,temp);
addImageSprite(temp);
}
}
为什么每次添加的图片都是程序资源的图片,不是我选中的照片呢?