I'm building an android app that can get images from the photos gallery.
two questions if I may:
1)
Intent intent = getIntent();
Bundle extras = intent.getExtras();
String action = intent.getAction();
Uri uri = null;
// if this is from the share menu
if (Intent.ACTION_SEND.equals(action)) {
if (extras.containsKey(Intent.EXTRA_STREAM))
{
try
{
// Get resource path from intent callee
uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
I have this uri:
content://media/external/images/media/27031
but my code fails here with no information (it just crashes), no log cat, not console error.
try {
if (uri !=null)
{
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
imageView.setImageBitmap(bitmap);
}
} catch (IOException e) {
e.printStackTrace();
Log.e(this.getClass().getName(), e.toString());
}
how can I solve this?
(it works for this url: Uri uri = Uri.parse("content://media/external/images/media/22719");
2) i plan to save all uri's in a data structure. That's the recommended way?
or is it better to keep the photos in a local app folder?
Update
I think the problem was that the failing image was on the external SD whereas the succeeding one was on a local SD.
How can i enable getting image from the external SD ?