How to Build Android Apps with Kotlin by Alex Forrester Eran Boudjnah Alexandru Dumbravan and Jomar Tigcal

How to Build Android Apps with Kotlin by Alex Forrester Eran Boudjnah Alexandru Dumbravan and Jomar Tigcal

Author:Alex Forrester, Eran Boudjnah, Alexandru Dumbravan and Jomar Tigcal
Language: eng
Format: epub
Publisher: Packt Publishing Pvt Ltd
Published: 2023-04-24T00:00:00+00:00


Next, override onCreate() to start the service as a foreground service and keep a reference of the Notification.Builder, and create serviceHandler: override fun onCreate() { super.onCreate() notificationBuilder = startForegroundService() val handlerThread = HandlerThread("RouteTracking").apply { start() } serviceHandler = Handler(handlerThread.looper) }

Note that to create the Handler instance, you must first initialize and start HandlerThread.

Define a call that tracks your deployed SCA as it approaches its designated destination: private fun trackToDestination(notificationBuilder: NotificationCompat.Builder) { val notificationManager = getSystemService(NOTIFICATION_ SERVICE) as NotificationManager for (i in 10 downTo 0) { Thread.sleep(1000L) notificationBuilder.setContentText( "$i seconds to destination").setSilent(true) notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build()) } }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.