본문 바로가기
IT/Android

Kotlin] 안드로이드 이미지 공유하기 // Android share image

by 깻잎쌈 2021. 3. 21.
반응형

이미지를 공유합니다,

버튼을 누르면 공유할 수 있는 앱이 나타납니다

 

 

button_share.setOnClickListener {
      val intent = Intent(Intent.ACTION_SEND)
      // 이미지 uri
      val uri: Uri = Uri.parse(imgUri.toString()) 

      intent.type = ("image/*")
      intent.putExtra(Intent.EXTRA_STREAM, uri)
      startActivity(Intent.createChooser(intent, "Share img"))
}

 

인텐트 이미지 타입을 image/png로 하면 공유가 안되는 앱도 있습니다.

  intent.type = ("image/*")

 

developers.facebook.com/docs/instagram/sharing-to-feed

developers.facebook.com/docs/instagram/sharing-to-stories

반응형

댓글