我从画廊拍摄了一张照片,我想在另一节课上使用它。是否可以使用“uri”?
Uri selectedImage = data.getData();
String path = selectedImage.getPath();
Intent sintent = new Intent(FromFile.this, OurView.class);
startActivity(sintent);
答案 0 :(得分:1)
创建意图后添加此项。
sintent.putExtra("image", path);
在OurView电话中
String path = getIntent().getStringExtra("image");
答案 1 :(得分:0)
您可以将要发送的图片的Uri
放在发件人Activity
的意图中。像这样:
Intent sintent = new Intent(FromFile.this, OurView.class);
intent.putExtra("selectedImage", selectedImage.toString());
startActivity(sintent);
然后要检索它,请在名为Activity
的{{1}}中使用此代码:
//Where OurView is assumed to be the class name of your Activity that is being called
Uri selectedImage = Uri.parse(OurView.this.getIntent().getExtras().getString("selectedImage"));
答案 2 :(得分:0)
1)如果要将Path传递给下一个Activity。试试这个 -
Intent sintent = new Intent(FromFile.this, OurView.class);
sintent.putExtra("pathvalue", path);
startActivity(sintent);
nextActivity(OurView.java)中的-
String path = getIntent().getStringExtra("image");
2)如果你想将Uri传递给下一个Activity。试试这个 -
Uri selectedImage = data.getData();
String path = selectedImage.getPath();
Intent intent = new Intent(FromFile.this, OurView.class);
intent.setData(Uri.parse(selectedImage));
startActivity(intent);
nextActivity(OurView.java)中的-
Uri selectedImage = getIntent().getData();