You can find detailed documentation at [https://docs.tryvital.io/
].
The Vital SDK is split into three main components: VitalClient
, VitalHealthConnect
and VitalDevices
.
VitalClient
holds common components to bothVitalHealthConnect
andVitalDevices
. Among other things, it has the network layer that allows us to send data from a device to a server.VitalHealthConnect
is an abstraction over Health ConnectVitalDevices
is an abstraction over a set of Bluetooth devices.
You can install the Vital SDK by adding the followings to your build.gradle
file:
repositories {
...
maven { url 'https://jitpack.io' }
}
implementation 'com.github.tryVital.vital-android:VitalClient:$vital_version'
implementation 'com.github.tryVital.vital-android:VitalHealthConnect:$vital_version'
implementation 'com.github.tryVital.vital-android:VitalDevices:$vital_version'
Replace $vital_version
with the latest version of the SDK. You only need to add the dependencies
for the components you want to use.
The min version of the SDK is 21
for VitalClient but for VitalHealthConnect and VitalDevices it is
26
.
You have no additional steps to take to use VitalClient.
The sdk compiles on min version 26
but to get data out of the underlying Health Connect SDK you
need to be on 28
or higher.
Vital Devices uses bluetooth and it requires different permissions based on your apps min version.
Here is an example of a AndroidManifest.xml
file that uses Vital Devices:
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<!-- Request legacy Bluetooth permissions on older devices. -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30"/>
First you need to get an instance of VitalClient
:
val client = VitalClient(
context = this,
region = Region.EU,
environment = Environment.Sandbox,
apiKey = "sk_eu_S5LdX..." //your key from the dashboard
)
Now you can start using the client to send and receive data from the server.
You can read about the available methods in the docs.
Coming soon.
To interact with Vital Devices sdk you need to get an instance of the VitalDeviceManager
:
val deviceManager = VitalDeviceManager.create(this)
Next you have to scan for one of the supported devices. You can find the list of supported devices
by calling VitalDeviceManagerBrands.devices
.
You can search now.
vitalDeviceManager.search(deviceModel).collect { scannedDevice ->
// scannedDevice is the device that was found of the type deviceModel
}
Depending on the type of device you are connecting to, you will have to call different methods to connect to it.
vitalDeviceManager.bloodPressure(context, scannedDevice)
.collect { bloodPressureSample ->
// bloodPressureSample is the sample that was received from the device
}
vitalDeviceManager.glucoseMeter(context, scannedDevice)
.collect { glucoseSample ->
// glucoseSample is the sample that was received from the device
}
After you have received samples depending on the type of device you might need to star scanning again to receive the next set of samples.