6

Hi I want to open image in gallery, below is my code

mImageView.setImageBitmap(AppUtil.getBitmapFromFile(obj.getImageUrl(), 200, 200));

    mImageView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse(obj.getImageUrl()), "image/*");
            startActivity(intent);
        }
    });

but its showing NullPointerException

Uri.parse(obj.getImageUrl() returns below string

/mnt/sdcard/Pictures/app_images/pro20130429_170323_-1793725321.tmp

update: now i tried
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("file://sdcard/Pictures/app_images/pro20130429_170323_-1793725321.tmp"))); and getting an error that

05-03 16:40:18.460: E/AndroidRuntime(4764): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file://sdcard/Pictures/app_images/pro20130429_170323_-1793725321.tmp }
Raja
  • 161
  • 1
  • 11
  • possible duplicate of [Open an image using URI in Android's default gallery image viwer](http://stackoverflow.com/questions/5383797/open-an-image-using-uri-in-androids-default-gallery-image-viwer) – Richard Le Mesurier Sep 08 '14 at 14:56

1 Answers1

4

try this one

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + "/sdcard/Pictures/app_images/pro20130429_170323_-1793725321.tmp"), "image/*");
startActivity(intent);
umesh
  • 1,148
  • 1
  • 12
  • 25