Skip to content

Instantly share code, notes, and snippets.

@qamarelsafadi
Created May 12, 2023 08:42
Show Gist options
  • Save qamarelsafadi/76bd7b52f835e09193a96a366d4bc82a to your computer and use it in GitHub Desktop.
Save qamarelsafadi/76bd7b52f835e09193a96a366d4bc82a to your computer and use it in GitHub Desktop.
// update your activity version
implementation 'androidx.activity:activity-ktx:1.7.1'
val pickMedia = registerForActivityResult(ActivityResultContracts.PickVisualMedia()) { uri ->
// Callback is invoked after the user selects a media item or closes the
// photo picker.
if (uri != null) {
// do what you want with pic
} else {
Log.d("PhotoPicker", "No media selected")
}
}
private fun pickImageFromGallery() {
pickMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
}
// to support all version put this in your Manifest file
<service
android:name=".data.notification.Controller"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment