[英]onActivityResult in android
in my application i'm retrieving image from sdcard and sending path of image back to previous activity.i'm not able to open image using that path.how can i do this. 在我的应用程序中,我正在从SD卡中检索图像并将图像的路径发送回先前的活动。我无法使用该路径打开图像。我该怎么做。
code - 代码-
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==1)
{
Uri path=data.getData();
File f;
System.out.println(";;;;;;;;;;;;"+path);//geting null
}
}
in 2nd activity- 在第二活动中
for(j=1;j<idcount;j++){
if(ch[j].isChecked())
{
System.out.println("PPPPPPPPPPPPPPPPPP"+j);
i=new Intent();
i.putExtra("files",image[++j]);// image is array of file
setResult(RESULT_OK, i);
finish();
}
}
Have you tried using the getDataString() method? 您是否尝试过使用getDataString()方法?
Also I am not sure if this is completely what you want, but you could try doing something like: 另外,我不确定这是否完全是您想要的,但是您可以尝试执行以下操作:
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
Uri uri = (Uri)bundle.get(Intent.EXTRA_STREAM);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.