Created
May 9, 2020 06:53
-
-
Save myrickchow32/87b762274bdc44c924e8d899e5e86001 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SharingActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_sharing) | |
val isActivityLaunchedFromActionSend = intent?.action == Intent.ACTION_SEND | |
val isImageData = intent.type?.startsWith("image/") == true | |
if (isActivityLaunchedFromActionSend && isImageData) { | |
handleSendImage(intent) | |
} | |
} | |
private fun handleSendImage(intent: Intent) { | |
(intent.getParcelableExtra<Parcelable>(Intent.EXTRA_STREAM) as? Uri)?.let { | |
Glide.with(this).load(it).into(imageView) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment