class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) } private val galleryLauncher = this.registerForActivityResult(ActivityResultContracts.GetMultipleContents()) { images -> for (image in images) { println(image.path) } } private fun openGallery() { galleryLauncher.launch("image/*") } fun onButtonClick(view: View) { openGallery(); } }
Select images from local storage
- Details
- Written by: Stanko Milosev
- Category: Android
- Hits: 205
My example how to select images from local storage: