开发者社区> 问答> 正文

使用文件路径在gallery中打开一个图像

我在数据库中存储一个图像文件路径。现在使用它我想打开 gallery 中 SD Card 的图像。
我使用的下面的代码:
screenshot
出现的错误:
screenshot
如何处理这个问题?

展开
收起
蛮大人123 2016-02-18 11:48:26 1894 0
1 条回答
写回答
取消 提交回答
  • 我说我不帅他们就打我,还说我虚伪
    Intent newintent = new  Intent(android.content.Intent.ACTION_VIEW);
    newintent.setDataAndType(Uri.parse(file.getAbsolutePath().toString()), "image/*");
    newintent.setFlags(newintent.FLAG_ACTIVITY_NEW_TASK);
    try{
          FileExplorer.this.startActivity(newintent);
       }
    catch(android.content.ActivityNotFoundException e){
    Toast.makeText(this, "没有找到合适的应用打开文件",1).show();
    }
    2019-07-17 18:43:51
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载