Stay organized with collections
Save and categorize content based on your preferences.
Discovery
@RequiresApi(value = 26) interface Discovery
Entry point for discovering devices.
Summary
Public functions
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# Discovery\n=========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/com/google/ambient/crossdevice/discovery/Discovery \"View this page in Java\")\n\n\n```\n@RequiresApi(value = 26) interface Discovery\n```\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nEntry point for discovering devices.\n\nSummary\n-------\n\n| ### Nested types ||\n|---------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Discovery.Companion](/reference/kotlin/com/google/ambient/crossdevice/discovery/Discovery.Companion) | |\n| [Discovery.OnDevicePickerResultListener](/reference/kotlin/com/google/ambient/crossdevice/discovery/Discovery.OnDevicePickerResultListener) | Interface to receive the result from the device picker, for use with [registerForResult](/reference/kotlin/com/google/ambient/crossdevice/discovery/Discovery#registerForResult(androidx.activity.result.ActivityResultCaller,com.google.ambient.crossdevice.discovery.Discovery.OnDevicePickerResultListener)). |\n\n| ### Public functions ||\n|---------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Participant](/reference/kotlin/com/google/ambient/crossdevice/Participant)`?` | [getParticipantFromIntent](/reference/kotlin/com/google/ambient/crossdevice/discovery/Discovery#getParticipantFromIntent(android.content.Intent))`(intent: `[Intent](/reference/kotlin/android/content/Intent)`)` Gets the participant from an incoming [Intent](/reference/kotlin/android/content/Intent). |\n| [DevicePickerLauncher](/reference/kotlin/com/google/ambient/crossdevice/discovery/DevicePickerLauncher) | [registerForResult](/reference/kotlin/com/google/ambient/crossdevice/discovery/Discovery#registerForResult(androidx.activity.result.ActivityResultCaller,com.google.ambient.crossdevice.discovery.Discovery.OnDevicePickerResultListener))`(` ` caller: `[ActivityResultCaller](/reference/kotlin/androidx/activity/result/ActivityResultCaller)`,` ` callback: `[Discovery.OnDevicePickerResultListener](/reference/kotlin/com/google/ambient/crossdevice/discovery/Discovery.OnDevicePickerResultListener) `)` Registers a callback for discovery. |\n\nPublic functions\n----------------\n\n### getParticipantFromIntent\n\n```\nfun getParticipantFromIntent(intent: Intent): Participant?\n```\n\nGets the participant from an incoming [Intent](/reference/kotlin/android/content/Intent). Used to begin the process of accepting a remote connection with a [Participant](/reference/kotlin/com/google/ambient/crossdevice/Participant). Returns null if the [Intent](/reference/kotlin/android/content/Intent) is not valid for getting a [Participant](/reference/kotlin/com/google/ambient/crossdevice/Participant). \n\n### registerForResult\n\n```\nfun registerForResult(\n caller: ActivityResultCaller,\n callback: Discovery.OnDevicePickerResultListener\n): DevicePickerLauncher\n```\n\nRegisters a callback for discovery. \n\n| Parameters ||\n|---------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|\n| `caller: `[ActivityResultCaller](/reference/kotlin/androidx/activity/result/ActivityResultCaller) | The calling activity or fragment. |\n| `callback: `[Discovery.OnDevicePickerResultListener](/reference/kotlin/com/google/ambient/crossdevice/discovery/Discovery.OnDevicePickerResultListener) | The callback to be called when devices are selected by a user. |\n\n| Returns ||\n|---------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|\n| [DevicePickerLauncher](/reference/kotlin/com/google/ambient/crossdevice/discovery/DevicePickerLauncher) | The launcher to use to show a device picker UI to the user. |"]]