【发布时间】:2013-09-21 15:39:31
【问题描述】:
我正在尝试发送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;
ModifiedImage 类:
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]);
}
}
有谁知道我做错了什么?
【问题讨论】:
-
-
@User1204501 我认为他的评论很清楚
标签: java android arrays string android-intent