gpt4 book ai didi

android - 如何在 Android 内置图库中打开外部图像(来自网络)

转载 作者:行者123 更新时间:2023-12-05 07:59:07 26 4
gpt4 key购买 nike

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

第一个答案对我不起作用。下面一个做了。

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

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

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

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

有什么简单的方法吗?如何在 native 内置的 android gallery 应用程序中打开带有 url 的图像??

最佳答案

试试这个:

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

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

希望对您有所帮助!

关于android - 如何在 Android 内置图库中打开外部图像(来自网络),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22776906/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com