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.

Lifecycle of the Background Read Service

The Validic Lifescan Background Read Service enables background connections to paired OneTouch Glucose meters by running as a foreground service. When started, it checks for paired devices and Bluetooth support, and will stop itself if either is unavailable. The service requires a foreground notification; if none is provided, a default notification will be shown. The service can be stopped at any time via the API, and will also stop itself on timeout.

Methods

  • ValidicLifeScan.getInstance(context).startBackgroundRead(params): Starts the background read service.
  • ValidicLifeScan.getInstance(context).stopBackgroundRead(): Stops the background read service.

Notifications

The service runs in the foreground and requires a notification. You can customize the notification and provide actions (e.g., to stop the service) using a PendingIntent.

Edge Cases

  • If no devices are paired or Bluetooth is unsupported, the service will no-op and stop itself.
  • Attempting to take a reading from an unpaired device may trigger the pairing flow (as per OneTouch MCK behavior).

Foreground Service Behavior on Android 15+

On Android 15 (API level 34) and above, the Lifescan Background Read Service uses different foreground service types depending on permissions:

  • If the app has been granted the BLUETOOTH_CONNECT permission, the service uses the FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE type. This is optimal for device connectivity and ensures the service is treated appropriately by the system.
  • If the permission is not granted, the service falls back to FOREGROUND_SERVICE_TYPE_DATA_SYNC, which is suitable for background data operations but may have different system restrictions and behaviors.

This distinction helps ensure the service operates reliably and complies with Android's background execution policies. The notification shown to the user will reflect the service's current state and type.

Service Timeout

Foreground services on Android 15+ are subject to stricter timeout policies. Foreground services have a maximum of 6 hours that they can run continuously. After this period, the system may stop the service if it is not actively performing a task that justifies its foreground status.