Language

HealthConnectManager.CreateMatchmakingIntent(MatchmakingRequest) Method

Definition

Creates an Intent to launch a Health Connect flow where users can: Discover compatible data sources: See other installed data sources that have not yet granted permissions to write some of the Record classes the calling app can read; Grant missing permissions: Easily grant these discovered data sources the necessary write permissions for health data record types that haven't been granted yet.

[Android.Runtime.Register("createMatchmakingIntent", "(Landroid/health/connect/MatchmakingRequest;)Landroid/content/Intent;", "GetCreateMatchmakingIntent_Landroid_health_connect_MatchmakingRequest_Handler", ApiSince=37)]
public virtual Android.Content.Intent CreateMatchmakingIntent(Android.Health.Connect.MatchmakingRequest request);
[<Android.Runtime.Register("createMatchmakingIntent", "(Landroid/health/connect/MatchmakingRequest;)Landroid/content/Intent;", "GetCreateMatchmakingIntent_Landroid_health_connect_MatchmakingRequest_Handler", ApiSince=37)>]
abstract member CreateMatchmakingIntent : Android.Health.Connect.MatchmakingRequest -> Android.Content.Intent
override this.CreateMatchmakingIntent : Android.Health.Connect.MatchmakingRequest -> Android.Content.Intent

Parameters

request
MatchmakingRequest

A MatchmakingRequest that contains: A non-null set of Record classes. If non-empty, the flow focuses on these specific types. If empty, the flow focuses on types for which the calling package has permission to read.; A non-null set of DataOrigin to include in matchmaking. If non-empty, only specified data origins are considered. App data origins must be visible to the calling app (declared in <queries>). Device data origins (from getDeviceDataSources(Executor,OutcomeReceiver)) do not require manifest declaration.; A non-null set of DataOrigin to exclude from matchmaking. If non-empty, specified data origins are EXCLUDED. App data origins must be visible to the calling app. Device data origins do not require manifest declaration.

Returns

An Intent configured to show the flow for discovering and managing write permissions for matching data origins. This intent must be launched using android.app.Activity.startActivityForResult(Intent,int). This value cannot be null.

Attributes

Remarks

Creates an Intent to launch a Health Connect flow where users can: Discover compatible data sources: See other installed data sources that have not yet granted permissions to write some of the Record classes the calling app can read; Grant missing permissions: Easily grant these discovered data sources the necessary write permissions for health data record types that haven't been granted yet. Only Record types the calling package is permitted to read are being considered This flow helps users connect new data sources to Health Connect, by matching record types readable by the calling package to appropriate writing data sources.

How to launch this IntentThis intent must be launched using the ActivityResultLauncher with an appropriate contract (e.g., ActivityResultContracts.StartActivityForResult), or the android.app.Activity.startActivityForResult(Intent,int) API. It is not designed to be used with a android.app.Activity.startActivity(Intent) call. The launched activity may return a result code (e.g., Activity.RESULT_OK or Activity.RESULT_CANCELED) indicating the user's interaction with the flow:; Activity.RESULT_OK: The user has successfully granted permissions to at least one application; Activity.RESULT_CANCELED: The user has canceled the flow, either by closing the activity or by not granting any permissions. Activity.RESULT_CANCELED can also occur if the intent was launched in a discouraged way when no matching apps are available. This can be avoided by ensuring isMatchmakingPossible(MatchmakingRequest,Executor,OutcomeReceiver) returns true before launching the intent

The launched flow will only show packages that have declared, but not yet been granted write permissions (that have not been denied by the user twice) for at least one of the relevant recordTypes, and for the relevant included/excluded data sources:; If recordTypes is not empty: The launched screen will focus on data sources capable of writing data for at least one of the specified health recordTypes. The user can then grant write permissions to these discovered data sources specifically for these types. Record types the calling app does not have permission to read are considered ignored; If recordTypes is empty: The system first determines all health data record types for which the calling package has already been granted read permission. The launched flow will then display data sources capable of writing any of these record types, where the user can grant write permissions for these types; If includedDataSources is not empty: Only data sources whose package names are present in this set are considered for matchmaking. If a data source is an app, the calling app must have visibility of the package name (e.g. declared in the manifest inside <queries>). If a data source is a device, the calling app does not need to declare it in the manifest, but should identify available devices via getDeviceDataSources(Executor,OutcomeReceiver); If excludedDataSources is not empty: Data sources whose package names are present in this set are excluded from matchmaking. As with inclusion, app data sources must be visible to the calling app, while device data sources do not require manifest declaration; If both are empty: All compatible data sources are considered.

Note: includedDataSources and excludedDataSources cannot both be non-empty at the same time.

Android reference for android.health.connect.HealthConnectManager.createMatchmakingIntent.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to