LifeScan Operations
Native Android ==> LifeScan module
Validic OneTouch module provides a convenience method to the Validic SDK for converting a BloodGlucoseRecord from the LifeScan MCK to an Inform Measurement object. This module must be used with the LifeScan OneTouch Mobile Connectivity Kit (MCK). Please reference the readme and documentation in the MCK for details on how to setup and implement it.
Background Connection Listener
To Connect to Lifescan Glucose Meters in the background (while using another app, or the screen is off) start the Validic Lifescan Service to connect and report information about previously paired One Touch Glucose meters that have been found in the background. To start add a BackgroundConnectionListener
to the ValidicLifescan
singleton.
The NotificationParams
are used to display a notification to end users while the connections are pending in the background. Notifications can be configured to contain an action to pause reading device information in the background until the next time startBackgroundRead
is called again.
Here is an example of building a Notification that has a PendingIntent action that will stop the background read service:
String notificationId = UUID.randomUUID().toString();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channel = new NotificationChannel(notificationId, "LifeScan Background " +
"Notification", NotificationManager.IMPORTANCE_DEFAULT);
notificationManager.createNotificationChannel(channel);
Intent serviceIntent = new Intent(context, LifescanBackgroundReadService.class);
serviceIntent.putExtra(LifescanBackgroundReadService.INTENT_KEY_STOP, true);
PendingIntent stopServicePendingIntent = PendingIntent.getService(context, 0, serviceIntent, 0);
Notification notification = new NotificationCompat.Builder(context, notificationChannelId)
.addAction(R.drawable.stop_action_icon_visible_pre_nougat, "Stop Service", stopServicePendingIntent)
.setContentTitle("Custom Content Title")
.setContentText("Helpful notification content.")
.setColor(ContextCompat.getColor(context, R.color.your_accent_color_perhaps))
.setSmallIcon(R.drawable.ic_icon_notification)
.build();
ValidicLifeScan.getInstance(context).addBackgroundConnectionListener((device, info) -> device.operations().getBloodGlucoseRecords(getActivity(), PreferenceManager.getDefaultSharedPreferences(getActivity()).getInt(device.getIdentifier(), 0), null, new CompletionListener<BloodGlucoseRecordResponse>() {
@Override
public void onSuccess(@NonNull OneTouchDevice oneTouchDevice, @Nullable BloodGlucoseRecordResponse bloodGlucoseRecordResponse) {
// store last anchor
PreferenceManager.getDefaultSharedPreferences(getActivity()).edit().putInt(oneTouchDevice.getIdentifier(), 0).apply();
}
}));
ValidicLifeScan.getInstance(context).startBackgroundRead(params);
If there are no paired One Touch Devices then starting background read will No-Op.
To stop background reading call:
ValidicLifeScan.getInstance(context).stopBackgroundRead();
Submitting Data to Validic
After you have received a BloodGlucoseRecordResponse
collecting Validic Measurements
can be done using the extension functions provided.
val bloodGlucoseResponse: BloodGlucoseRecordResponse
val oneTouchDevice: OneTouchDevice
lifecycleScope.launch {
val measurements:List<Measurement> = bloodGlucoseResponse.asInformMeasurements(oneTouchDevice)
// Submit Measurements to Validic
measurements.forEach { m ->
SessionV2.getInstance().queue(m)
}
}
Special Considerations
- The Validic native library module for OneTouch requires a license file from LifeScan, that must be provided for their SDK, and also the Validic OneTouch module to function.
- Attempting to take a reading from an unpaired device can start the pairing flow. This is a feature of the OneTouch MCK and cannot be overriden.
Updated 4 days ago