Kotlin and Android



Android now officially supports the object-oriented programming language Kotlin.

A plugin for Kotlin is embedded in Android Studio (starting from version 3.0).

See the article from the official Android documentation: https://developer.android.com/kotlin/index.html


Tagging principles with Kotlin

Kotlin is entirely supported by Android Studio 3.0, so it’s relatively simple to create new projects containing Kotlin files, add Kotlin files to an existing project, or convert Java code into Kotlin (see the “Get Started with Kotlin” section of the official documentation for more details).

Kotlin enables full interoperability with Java language. This is why the operating principles and the integration methods documented in your “Getting started” section remain unchanged.

Android Studio 3.0 offers different conversion tools. It’s therefore possible to convert a Java file (with a .java extension) into a Kotlin file (with a .kt extension) by opening the file, then by selecting the menu Code > Convert Java File to Kotlin File. You may also create a new Kotlin file (menu File > New > Kotlin File/Class) and then insert Java code. In this case, a dialog box will open, asking if you wish to automatically convert the code. The examples of Android tagging defined in Java can therefore be inserted as is, leading to automatic conversion.


Tagging example

Tagging a Gesture with Debugger in Java

Equivalent tagging in Kotlin

Was this post helpful?
Last update: 03/01/2018