当使用getextra方法时,Alway获取空值,我在一个活动上添加额外的活动并在其他活动上接收,我的代码是
super.onActivityResult(requestCode, resultCode, data);
String filePath="";
Intent intent1 = new Intent(TagActivity.this,AddnewNoteActivity.class);
if(requestCode==1)
{
}
else if(requestCode==2)
{
if(resultCode == RESULT_OK)
{
intent1.putExtra("path", data.getData());
intent1.setType("image/*");
}
}
else if(requestCode==3)
{
if(resultCode == RESULT_OK){
intent1.putExtra("path", data.getData());
intent1.setType("audio/*");
}
}
startActivity(intent1);
}
在接收方
if(imageUri==null)
{
extras = getIntent().getExtras();
if (extras != null) {
String Path;
Path= extras.getString("path");
imageUri = Uri.parse(Path);
}
}
Nuth每次在Path中收到null,请帮忙
答案 0 :(得分:0)
问题解决为
intent1.putExtra(“path”,data.getData() .tostring()); //在发件人方面