View image in native imageViewer in android - android

I have retrieved the uri of the image
But when i use
startActivity(new Intent(Intent.ACTION_VIEW,mediaUri));
the image is viewed in image viewer but i can also see other gallery images.
How to avoid this.
I only want the single image to open in image viewer.

This may help you
Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("file:///sdcard/path/to/myfile.png"),"image/png");
startActivity(i);

Related

share image intent image is an actually url of image not an application resource

Actually I am getting all rss feed from here
Now I all complete with my code But I want to add one functionality of share image.
Now I have image linke for ex.
http://miscmedia-9gag-lol.9cache.com/images/long-post-cover/12796580_1414746906.7976_Ejy2yj_460c.jpg link
How can I share this image like sharing an regular image.
I solved such issue by downloading image before sharing. (If you display images in your app using library like universal image loader or implemented such functionality on your own the only thing you need to do is to find predownloaded image on file system) If image is not large it will not take much time to download. Then you can delete image file after sharing.
try this,
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, imageurl);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share images to..");

open part of web page in android using uri intent

I have an android app that lists items with url links and on clicking opens the pages using uri,
as below
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
I would like to open only for example a video or image in that page but not the whole of it.
Is that possible in android?
I got what you want to ask.
NO, it is not possible with Intent to open a part of a webpage, it will open entire page,
I suggest you to
1. download and save the image to your drawable folder.
2. create a new actvity , and in the xml associated with that activity add a imageview
3. place your image in that imageview
4. and on the click of the link start the activity with the intent
I would suggest to either use an ImageView (load the image into it - Download image for imageview on Android) or a VideoView (as stream - http://code.tutsplus.com/tutorials/streaming-video-in-android-apps--cms-19888).
It's not possible with an intent.

How to open External Image (from web) in Android in-built gallery

I want to open an image from the web inside in-built android gallery image viewer. So I searched. Found this link
StackOverflow
First answer didn't work for me. Following one did.
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com/example.jpg")));
BUT It opened the image into browser. I want it to open this with in-built image viewer of android.
Rest of the things that I found work with the local image, not from web.
Basically the idea is to use a method that will open the image in native app, and I'll call that method with Cordova/Phonegap.
Is there any simple way to do it? How can I open the image with url in the native in-built android gallery app??
Try this:
public void openImage(String image) {
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI.buildUpon().appendPath(image).build();
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
Pass your image path to this method and see if it works.
Hope this has helped!

Android load image from url and save to phone

Currently I have the following:
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(mediaLoc)), "image/" + type);
context.startActivity(intent);
This was because the app used to download images from urls and saved them into the sdcard before viewing. But now I want to change the implementation to show the image from a url in the default image viewer when ACTION_VIEW is called and give them the option to save. Is this possible with ACTION_VIEW? I'm asking because I wish to use the default image viewer in the phone as it has already handled the zoom functions.
You would have to make a custom action_view for it.

How to capture an image and set it as attachment from an application?

I want to launch the camera from my application and want to use the captured image as an attachment in my application.
The use case is as below:
Press the capture button in the application->Opens camera application -> capture an image->the image is shown as thumbnail in my application.
Any suggestions, ideas, would be very helpful.
Image capture step description:
Get Path of image from ACTION_IMAGE_CAPTURE Intent
After that, you have path of the fetched image. Then you can use it for your purpose. Show it as small Bitmap, and attach the original to further processing.
To view captured image, send the intent
Intent viewImageIntent = new Intent();
viewImageIntent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File(imageFilePath);
viewImageIntent.setDataAndType(Uri.fromFile(file), "image/*");
viewImageIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(viewImageIntent);

Categories

Resources