Tag Archives: kotlintutorial

Ranges in Kotlin

Kotlin provides a unique type for a range of values. A range has a start and an end value.


To create a range you can use the rangeTo() function.

This code defines a range variable myRange containing values from 1 to 10 inclusive.

Ranges in Kotlin are closed, this mean that the start value and the end value are included in the range.

Continue reading Ranges in Kotlin

Follow and like us:

The do-while loop

The do-while loop first executes the loop statements before evaluating the expression. It means that the statements in a do-while loop will always run at least once, even the condition evaluates to false.

 The syntax

When the program runs, code inside do block is executed once without testing the condition. After that, condition is tested.

Continue reading The do-while loop

Follow and like us:

Run, with, let, also and apply

Some of the Kotlin’s standard functions are so similar that we are not sure which to use. Here I will introduce a simple way to clearly distinguish their differences and how to pick which to use.

Scoping functions

The functions that I’ll focus on is run, with, T.run, T.let, T.also and T.apply. I call them scoping functions as I view their main functionality as provide an inner scope for the caller function.

Continue reading Run, with, let, also and apply

Follow and like us:

Timer Application with Handler

In this tutorial we will learn how to make your own Timer with Start, Pause, Resume and Stop statements. We will use here a Handler, what allows us to send and process message and runnable objects.

To create a timer application, we have more options. For example we can use a Timer or a CountDownTimer.

Continue reading Timer Application with Handler

Follow and like us:


A Service (like ForegroundService) is an application component that can perform long-running operations in the background, and it doesn’t provide a user interface.

Another application component can start a service, and it continues to run in the background even if the user switches to another application. Additionally, a component can bind to a service to interact with it. For example, a service can handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background.

Continue reading ForegroundService

Follow and like us: