Gibran Gul
Gibran Gul

Reputation: 121

Opening image in a gallery view

Here is my onclick listener for in image obtained from the gallery:

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

How ever when i click on the image it just shows a blank black screen with the gallery's controls visible. What should i do?

Upvotes: 0

Views: 2498

Answers (1)

Nirmal
Nirmal

Reputation: 2368

                        Intent intent = new Intent();
                         intent.setAction(Intent.ACTION_VIEW);
                         Uri imgUri = Uri.parse("file://" + yourfilepath);
                         intent.setDataAndType(imgUri, "image/*");
                         startActivity(intent);

Hope this will work for you.

Upvotes: 2

Related Questions