3

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??

Community
  • 1
  • 1
AtanuCSE
  • 8,832
  • 14
  • 74
  • 112

1 Answers1

0

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!

gilonm
  • 1,829
  • 1
  • 12
  • 22
  • 2
    Giving me an error. `E/AndroidRuntime(7358): FATAL EXCEPTION: WebViewCoreThread 04-01 11:55:48.297: E/AndroidRuntime(7358): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://media/external/images/media/http%3A%2F%2Ftest1.latechnologies.net%2Fbanglaporjotonimg%2Fpotenga2.jpg } 04-01 11:55:48.297: E/AndroidRuntime(7358): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409) 04-01 11:55:48: E/AndroidRuntime(7358): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379) ` – AtanuCSE Apr 01 '14 at 05:52