Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to open bitmap in gallery in android

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 }
like image 615
Raja Avatar asked May 03 '13 10:05

Raja


People also ask

How do I view bitmap in Android?

The ImageView class is pointed at a bitmap stored under one of the drawable folders in the res project folders. Start by creating a basic app project that will contain the ImageView and bitmap to display. Here the new project created in Android Studio is called Bitmap and an Empty Activity used.

What is bitmap image in Android?

A bitmap (or raster graphic) is a digital image composed of a matrix of dots. When viewed at 100%, each dot corresponds to an individual pixel on a display. In a standard bitmap image, each dot can be assigned a different color. In this instance we will simply create a Bitmap directly: Bitmap b = Bitmap.

How do I save a picture on my Android Gallery?

Touch and hold the image. Select a save option (e.g., Save attachment, Save to SD card, etc.). Unless otherwise specified, the image is saved to the default picture/video location (e.g., Gallery, Photos, etc.).

What is Bitmap class in Android?

Bitmap) class represents a bitmap image. You create bitmaps via the BitmapFactory (android. graphics. BitmapFactory) class. Using a BitmapFactory, you can create bitmaps in three common ways: from a resource, a file, or an InputStream.


1 Answers

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);
like image 126
umesh Avatar answered Sep 23 '22 22:09

umesh