【问题标题】:How to open External Image (from web) in Android in-built gallery如何在 Android 内置图库中打开外部图像(来自网络)
【发布时间】:2014-04-01 04:37:52
【问题描述】:

我想在内置的 android 图库图像查看器中打开来自网络的图像。所以我搜索了一下。找到这个链接 StackOverflow

第一个答案对我不起作用。以下是一个。

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com/example.jpg")));

但是它将图像打开到浏览器中。我希望它用 android 的内置图像查看器打开它。

我发现的其他内容适用于本地图像,而不是来自网络。

基本上,这个想法是使用一种在本机应用程序中打开图像的方法,我将使用 Cordova/Phonegap 调用该方法。

有什么简单的方法吗?如何在原生内置的 android 图库应用中打开带有 url 的图像??

【问题讨论】:

  • 网页是本地的还是来自互联网的?
  • @BirajZalavadia 哪个网页?应用程序是用 Cordova 构建的。所以页面是本地的。图片来自我想用安卓原生应用打开的网络。

标签: android image


【解决方案1】:

试试这个:

 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);
}

将你的图片路径传递给这个方法,看看它是否有效。

希望这有帮助!

【讨论】:

  • 给我一个错误。 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)
猜你喜欢
  • 1970-01-01
  • 2014-09-29
  • 1970-01-01
  • 2013-05-02
  • 2017-12-29
  • 1970-01-01
  • 2011-04-27
  • 1970-01-01
  • 2010-11-17
相关资源
最近更新 更多