1

Currently I have the following code that allows a user to choose an image.

int requestCode = 1337;

Intent chooserIntent = new Intent(Intent.ACTION_GET_CONTENT);
chooserIntent.setType("image/*");
chooserIntent = Intent.createChooser(chooserIntent, "Please choose a picture");
chooserIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivityForResult(chooserIntent, requestCode);

My question is:

does Android guarantee that the returned Uri is always pointing to a location on disk, or is it possible that it might be pointing to somewhere on the internet too?

P.S. although I am not sure about this, the Uri returned by this piece of code seems to always start with content:// - I am not sure whether or not this holds for all possible return values, I thought I would just add this here to help out any possible question answerers.

Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
AlanSTACK
  • 5,525
  • 3
  • 40
  • 99

1 Answers1

1

does Android guarantee that the returned Uri is always pointing to a location on disk, or is it possible that it might be pointing to somewhere on the internet too?

It is possible to have Uri other than local disk i.e. it can be remotely as well. You will get URL from remote then convert it to Uri and use it.

From official docs:

An ACTION_GET_CONTENT could allow the user to create the data as it runs (for example taking a picture or recording a sound), let them browse over the web and download the desired data, etc.

Convert Url to a Uri (Reference):

Uri uri =  Uri.parse( "http://www.facebook.com" );
Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104