How can I attach an image file in email?

后端 未结 3 1244
独厮守ぢ
独厮守ぢ 2020-12-06 07:33

I want to attach an image with email, that image is stored in /data/data/mypacke/file.png. How can I attach that image file programmatically? What would sample

3条回答
  •  一生所求
    2020-12-06 08:02

    Use Intent.ACTION_SEND to hand the image off to another program.

    File F = new File("/path/to/your/file.png");
    Uri U = Uri.fromFile(F);
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("image/png");
    i.putExtra(Intent.EXTRA_STREAM, U);
    startActivity(Intent.createChooser(i,"Email:"));
    

提交回复
热议问题