0

使用 getextra 方法时总是得到空值,我在一个活动上添加额外内容并在另一个活动上接收,我的代码是

    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,请帮忙

4

1 回答 1

0

问题解决为

intent1.putExtra("路径", data.getData() .tostring() ); //在发送方

于 2013-03-25T18:58:19.177 回答