Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass a URI to an intent?

I'm trying to pass a URI-Object to my Intent in order to use that URI in another activity.

How do I pass a URI?

private Uri imageUri; .... Intent intent = new Intent(this, GoogleActivity.class); intent.putExtra("imageUri", imageUri); startActivity(intent); this.finish(); 

How do I use now this URI in my other activity?

 imageUri = extras.getString("imageUri"); // I know thats wrong ... 
like image 541
Robert El Avatar asked Nov 05 '11 00:11

Robert El


People also ask

How do I send intent to another app?

Sending binary contentIntent shareIntent = new Intent(); shareIntent. setAction(Intent. ACTION_SEND);

What is Uri parse in android?

It is an immutable one-to-one mapping to a resource or data. The method Uri. parse creates a new Uri object from a properly formated String .


1 Answers

you can store the uri as string

intent.putExtra("imageUri", imageUri.toString()); 

and then just convert the string back to uri like this

Uri myUri = Uri.parse(extras.getString("imageUri")); 
like image 98
Lukap Avatar answered Oct 08 '22 22:10

Lukap