我正在尝试发送一个array of Strings
基本上包含设备上文件路径的文件。首先是用户Selects Picture 1
,然后是Select Picture 2
. 一旦用户完成,数组就会被加载并传递给下一个活动。当尝试接收变量时返回NullPointer
。
主要活动:
case SELECT_PICTURE1:
if (resultCode == RESULT_OK) {
// code here that gets the image path
// String leftImagePath contains the path of selected Image
// Used toast to display the image path and it is not null
finished = true;
}
break;
case SELECT_PICTURE2:
if (resultCode == RESULT_OK) {
//similar to Select Picture 1
// String rightImagePath contains the path of selected Image
if (finished == true) {
Bundle b = new Bundle();
b.putStringArray("stringArray", new String[] {
LeftImageString, RightImageString });
Intent i = new Intent(MainActivity.this, modifiedImage.class);
i.putExtras(b);
// finished = false;
}
}
break;
修改图像类:
Intent intent = getIntent();
_imagesPath = intent.getStringArrayExtra("IMAGES_PATH");
Bundle b= this.getIntent().getExtras();
_userImagePath = b.getStringArray("stringArray");
if (_imagesPath == null) {
for (int i = 0; i <= 1; i++) {
//null pointer on the following line because _userImagePath contains nothing.
_imagesPath[i] = _userImagePath[i];
_originalBitmaps[i] = BitmapFactory.decodeFile(_imagesPath[i]);
}
}
有谁知道我做错了什么?