Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to launch ActivityResultLauncher for picking contact?

I need to get contact info from activity which is out of my app. I read doc and try getting info as doc says. I can’t understand what argument I must pass to launch method of ActivityResultLauncher.

private val getContact = registerForActivityResult(
    ActivityResultContracts.PickContact()
) { uri: Uri? ->
    Log.d(TAG, uri.toString())
}

....

button.setOnClickListener {
    getContact.launch() // here launch requires argument of type Void?
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can pass in null or use the extension method from activity-ktx specifically for ActivityResultLauncher<Void?> that means you don’t need to pass anything at all:

import androidx.activity.result.launch
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading