Category kotlin

Location-Aware Apps with Google Maps

Create a new project and make sure to select Google Maps Activity in the Create New Project template wizard. 2. Add a Button “Find Location” in the Main Layout. activity_main.xml MainActivity.kt (no changes) 2. Update the MapsActivity.kt to includes codes…

Android External Storage in Kotlin

First of all, create an Activity in your project that will have a layout similar to below. You will need; Three buttons tp check, save and read external storage. One TextView to display results. activity_external_storage.xml ExternalStorageActivity.kt View the file created…

Functions in Kotlin

Functions A function is a block of codes with an assigned unique name that will perform a specific task The advantage of using a function is that you can call it by its name as often as needed thus reducing…

Control Flow Statements in Kotlin

The statements in your program generally executed from top to bottom. Control flow statements allows the execution to be broken/interrupted by applying decision making, iteration, branching or conditionally execute a partial part of the program. This article discuss the decision-making…

Getting User Input into a Kotlin Program

To read a user input from a Kotlin program, use the readLine() function. The readLine() function allows the program’s user to enter a string values or intercept keyboard input from the console. When you run the program, the output will…

Kotlin: Data Type Conversions

From time to time, you might need to convert (i.e. casting) a variable from one data type to another. Example such as converting a string to a number. Kotlin contains predefined functions that allows you to do the data type…

Kotlin Data Types

The basic data types used in Kotlin are strings, characters, booleans, numbers and arrays. String Use double-quotes to define a string. Used to store words or sentences. Character Use single-quote to define a character. Used to store a single character.…

Kotlin Variables: Mutable vs Immutable

In Kotlin, there are two types of variables; mutable variable and immutable variable. Mutable Variables Mutable variable is a variable whose value can be changed or updated from time to time. To declare a mutable variable, we use the var…