当共享与Intent.createChooser图像,我的文件消失了! [英] When sharing an image with Intent.createChooser, my file disappears!

查看:233
本文介绍了当共享与Intent.createChooser图像,我的文件消失了!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void share() {

    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("image/png");

    share.putExtra(Intent.EXTRA_STREAM,
      Uri.parse("file://" + filename));

    startActivity(Intent.createChooser(share, "Share Tag"));

}

我实现了这个简单的功能,必须从菜单中调用,但之后我称呼它,我的共享文件完全消失 - 就好像中所占的份额删除它从我的存储空间。为什么这样做,以及如何阻止它?

I implemented this simple function to be called from a menu, yet after I call it, the file I shared completely disappears -- it's as if the share is deleting it off of my storage. Why is it doing this, and how do I stop it??

推荐答案

尝试,而不是做这样的:

Try doing this instead:

Uri uri = Uri.fromFile(new File(filename));
share.putExtra(Intent.EXTRA_STREAM, uri);

这篇关于当共享与Intent.createChooser图像,我的文件消失了!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆