Syex
Syex

Reputation: 1350

Select a picture from asset folders in Android

I want the user to be able to select a picture from a given set of pictures that come with my app.

Is it possible to use new Intent(Intent.ACTION_PICK) but not with media files on the phone of the user, but with some pictures/bitmaps I defined earlier? So far I only found examples to pick images from the gallery.

Upvotes: 0

Views: 309

Answers (2)

Shadow
Shadow

Reputation: 6899

No.Intent(Intent.ACTION_PICK) choose picture from Gallery in your phone.

   private static final int SELECT_PHOTOS = 100;
   Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
  photoPickerIntent.setType("image/*");
  startActivityForResult(photoPickerIntent, SELECT_PHOTOS);

For asset folder Check this

 try 
 {
// get input stream
InputStream inputStream = getAssets().open("avatar.jpg");
// load image as Drawable
Drawable d = Drawable.createFromStream(inputStream, null);
// set image to ImageView
mImage.setImageDrawable(d);
 }
catch(IOException ex) 
{
return;
 }

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006944

No, sorry, there is no ACTION_PICK that will pick images from your project's assets/ folder. You would need to create your own UI for that.

Upvotes: 1

Related Questions