Class PolarCompanionDeviceManager

    • Constructor Detail

      • PolarCompanionDeviceManager

        PolarCompanionDeviceManager(Context context)
    • Method Detail

      • isAvailable

         final Boolean isAvailable()
        Returns:

        true if CDM is available on this device/OS version for this instance.

      • buildAssociationRequest

         final AssociationRequest buildAssociationRequest(String namePrefix, List<UUID> serviceUuids, Boolean singleDevice, String macAddress)

        Builds an AssociationRequest that matches nearby BLE devices advertising one of the given serviceUuids, optionally restricted to devices whose name starts with namePrefix.

        Parameters:
        namePrefix - optional required BLE device name prefix, e.g.
        serviceUuids - BLE advertised service UUIDs to match, e.g.
        singleDevice - if true, the system association dialog will only allow single selection and, on API 33+, may skip the dialog entirely if exactly one strong match is found.
        macAddress - optional BT MAC address; when set, only that exact device can match, so the chooser can never offer (or auto-pick) a different nearby device.
      • launchAssociation

         final Unit launchAssociation(Activity activity, IntentSender intentSender, Integer requestCode)

        Convenience helper for launching the association IntentSender from an Activity using the legacy startIntentSenderForResult API (for callers not yet using the Activity Result APIs). Prefer ActivityResultContracts.StartIntentSenderForResult when possible.

      • requestBackgroundExecutionPrivilege

         final Boolean requestBackgroundExecutionPrivilege(Activity activity, Integer requestCode)

        Requests the "run in background" companion app privilege (API 33+). This relaxes background execution / BLE scan throttling limits normally imposed on apps once they are backgrounded, for apps that are companion apps of an associated device. Must be called from an Activity; the result is delivered to onActivityResult(requestCode, ...) of that activity (or via an ActivityResultLauncher<Intent>).

        Note: the REQUEST_COMPANION_RUN_IN_BACKGROUND action constant is not exposed in the public Android SDK stubs (compileSdk), so the documented action string literal is used directly.

        Returns:

        true if the request intent was launched, false if not supported/available.

      • isAvailable

         final static Boolean isAvailable(Context context)
        Returns:

        true if the Companion Device Manager APIs are available on this OS version and this device supports the companion device setup feature.