Android 我怎样才能使用;uri“;将图像发送到另一个类?(安卓)
我从图库中拍摄了一张图片,我想在另一堂课上使用它。使用“uri”有可能吗Android 我怎样才能使用;uri“;将图像发送到另一个类?(安卓),android,image,uri,Android,Image,Uri,我从图库中拍摄了一张图片,我想在另一堂课上使用它。使用“uri”有可能吗 在创建意图后添加此项 sintent.putExtra("image", path); 在我们看来 String path = getIntent().getStringExtra("image"); 您可以将要发送的图像的Uri放入发件人的活动中。大概是这样的: Intent sintent = new Intent(FromFile.this, OurView.class); intent.putExtra("se
在创建意图后添加此项
sintent.putExtra("image", path);
在我们看来
String path = getIntent().getStringExtra("image");
您可以将要发送的图像的
Uri
放入发件人的活动中。大概是这样的:
Intent sintent = new Intent(FromFile.this, OurView.class);
intent.putExtra("selectedImage", selectedImage.toString());
startActivity(sintent);
然后,要检索它,请在名为的活动中使用此代码:
//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"));
1) 如果要将路径传递到下一个活动。试试这个-
Intent sintent = new Intent(FromFile.this, OurView.class);
sintent.putExtra("pathvalue", path);
startActivity(sintent);
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)中-
2) 如果要将Uri传递给下一个活动。试试这个-
Intent sintent = new Intent(FromFile.this, OurView.class);
sintent.putExtra("pathvalue", path);
startActivity(sintent);
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
最好使用java.lang.String)或类似内容
Uri selectedImage = getIntent().getData();