티스토리 뷰

1
2
3
4
5
6
7
8
9
10
11
12
private void shareImage() {
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("image/*");
    // setType("image/png"); OR for jpeg: setType("image/jpeg")
 
    String imagePath = Environment.getExternalStorageDirectory() + "/myImage.png";
    File imageFileToShare = new File(imagePath);
    Uri uri = Uri.fromFile(imageFileToShare);
    share.putExtra(Intent.EXTRA_STREAM, uri);
 
    startActivity(Intent.createChooser(share, "Share image to..."));
}
cs

file:///.... 경로를 만들기 위해 String, File, Uri를 이용해 형 변환 함..




댓글