onInitialize method

  1. @override
void onInitialize(
  1. Measure measure
)
override

Callback for initialization of probe.

Note that this is a non-async method and should hence be 'light-weight' and not block execution for a long duration.

Implementation

@override
void onInitialize(Measure measure) {
  super.onInitialize(measure);
  if (!Platform.isAndroid)
    throw SensingException('TextMessageProbe only available on Android.');

  Telephony.instance.listenIncomingSms(
    onNewMessage: (SmsMessage message) {
      _textMessageProbeController.add(TextMessageDatum.fromTextMessage(
          TextMessage.fromSmsMessage(message)));
    },
    onBackgroundMessage: backgrounMessageHandler,
  );
}