Computer scienceMobileAndroidAndroid CoreData structures

Activity communication: returning data

Register a callback

Report a typo

You are required to register a result callback and save the returned ActivityResultLauncher to a variable getContent using the predefined contract GetContent. The contract defines the result as a nullable Uri. In the callback, pass the result to the function processContent() only if it is not null; if it is null, ignore it.

The function signature of processContent() is processContent(uri: Uri): Unit hence it does not accept null values. You can access the contract as GetContent or ActivityResultContracts.GetContent.

Write a program in Kotlin
// Do not change the variable's name
val getContent =

Create a free account to access the full topic