【问题标题】:Android How to preview an image, using its file path from SDcard, from my applicationAndroid 如何在我的应用程序中使用 SDcard 中的文件路径预览图像
【发布时间】:2010-09-29 11:00:59
【问题描述】:

文件存在于sdcard/image.jpg
我想创建自己的应用程序(活动)。 按下按钮后,存储在 sdcard 中的图像需要使用内置的图像查看器显示。 从图像查看器按后退按钮后,它应该返回到我正在运行的应用程序。

需要帮助。

【问题讨论】:

    标签: android image view preview


    【解决方案1】:

    您可以为此创建一个具有适当 uri 和 mimetype 的 Intent。

    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setDataAndType(Uri.parse("file:///sdcard/image.jpg"), "image/jpeg");
    startActivity(i);
    

    【讨论】:

      【解决方案2】:
      Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
      photoPickerIntent.setType("image/*");
      startActivityForResult(photoPickerIntent, 1);
      

      此代码用于显示 SD 卡中的所有图像

      【讨论】:

        猜你喜欢
        • 2014-12-22
        • 1970-01-01
        • 1970-01-01
        • 2019-10-29
        • 1970-01-01
        • 1970-01-01
        • 2014-07-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多