diff --git a/app/src/main/java/org/hydev/wearsync/MyService.kt b/app/src/main/java/org/hydev/wearsync/MyService.kt index 69b255e..ba9d388 100644 --- a/app/src/main/java/org/hydev/wearsync/MyService.kt +++ b/app/src/main/java/org/hydev/wearsync/MyService.kt @@ -18,6 +18,7 @@ import org.hydev.wearsync.bles.BluetoothHandler.Companion.ble import org.hydev.wearsync.bles.decoders.BatteryDecoder import org.hydev.wearsync.bles.decoders.HeartRateDecoder import org.hydev.wearsync.bles.decoders.IDecoder +import timber.log.Timber import java.util.concurrent.atomic.AtomicLong @@ -50,7 +51,7 @@ class MyService : Service() private fun add(it: Any) = scope.launch { runCatching { - println("Adding ${it.javaClass.simpleName} to influxdb") + Timber.d("Adding ${it.javaClass.simpleName} to influxdb") influx add it "Recorded ${count.addAndGet(1)} events!".notif() @@ -61,8 +62,8 @@ class MyService : Service() override fun onReceive(ctxt: Context, intent: Intent) { add(intent.batteryInfo(bm)) } } - private val intent = PendingIntent.getActivity(this, 0, intent(), - PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) + private val intent by lazy { PendingIntent.getActivity(this, 0, intent(), + PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) } private fun String.notif() = startForeground(NOTIF_ID, NotificationCompat.Builder(this@MyService, NOTIF_CHANNEL_ID)