Created
May 12, 2023 08:42
-
-
Save qamarelsafadi/76bd7b52f835e09193a96a366d4bc82a 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
// 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
Is Photo picker is only worked android 13 and above.