How to send a uri
path of an image to another activity and convert it to image. I tried the below
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1 && resultCode == RESULT_OK && data != null && data.getData() != null) {
//file name
Uri selectedImage = data.getData();
Intent i = new Intent(this,
AddImage.class);
i.putExtra("imagePath", selectedImage);
startActivity(i);
and get it like this
String imagePath = getIntent().getStringExtra("imagePath");
imageview.setImageURI(Uri.parse(imagePath ));
How do I pass a URI? private Uri imageUri; .... Intent intent = new Intent(this, GoogleActivity. class); intent.
An Intent is a messaging object you can use to request an action from another app component. Although intents facilitate communication between components in several ways, there are three fundamental use cases: Starting an activity. An Activity represents a single screen in an app.
Convert you URI
to String while adding to Intent
like given below
i.putExtra("imagePath", selectedImage.toString());
and in your NextActivity
get the String
and convert back to URI
like ->
Intent intent = getIntent();
String image_path= intent.getStringExtra("imagePath");
Uri fileUri = Uri.parse(image_path)
imageview.setImageURI(fileUri)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With