Saturday, 14 September 2013

MediaStore.Images.Media.getBitmap gets images only from local SD?

MediaStore.Images.Media.getBitmap gets images only from local SD?

I'm building an android app that can get images from the photos gallery.
here is my code, but it succeed on getting images from local SD only.
how can I adjust it to get ones from external SD?
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());
}
at any rate, why dont I see any exception thrown? just a crash?
and why does the uri differ from the path I see after clicking photo ->
properties?

No comments:

Post a Comment