How to launch ActivityResultLauncher for picking contact?

495 Views Asked by At

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?
}
1

There are 1 best solutions below

0
ianhanniballake On BEST ANSWER

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