Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 我怎样才能使用;uri“;将图像发送到另一个类?(安卓)_Android_Image_Uri - Fatal编程技术网

Android 我怎样才能使用;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

我从图库中拍摄了一张图片,我想在另一堂课上使用它。使用“uri”有可能吗


在创建意图后添加此项

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();