Top "Kotlin" questions

Kotlin is an open-source, statically typed programming language supported and developed by JetBrains.

How to make primary key as autoincrement for Room Persistence lib

I am creating an Entity (Room Persistence Library) class Food, where I want to make foodId as autoincrement. @Entity class …

android kotlin android-room
Constants in Kotlin -- what's a recommended way to create them?

How is it recommended to create constants in Kotlin? And what's the naming convention? I've not found that in the …

android kotlin constants
Default interface methods are only supported starting with Android N

I upgraded to android studio 3.1 and I'm getting the following error: Default interface methods are only supported starting with Android …

android java-8 kotlin
startForeground fail after upgrade to Android 8.1

After upgrading my phone to 8.1 Developer Preview my background service no longer starts up properly. In my long-running service I've …

android service kotlin android-notifications background-service
How can I get a random number in Kotlin?

A generic method that can return a random integer between 2 parameters like ruby does with rand(0..n). Any suggestion?

random kotlin jvm
Kotlin - Property initialization using "by lazy" vs. "lateinit"

In Kotlin if you don't want to initialize a class property inside the constructor or in the top of the …

properties kotlin
How to create empty constructor for data class in Kotlin Android

I have 10+ variables declared in Kotlin data class, and I would like to create an empty constructor for it like …

android kotlin
Android Animation Alpha

I've got animation: <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator"&…

java android animation kotlin alpha
Kotlin - Idiomatic way to check array contains value

What's an idiomatic way to check if an array of strings contains a value in Kotlin? Just like ruby's #include?. …

arrays kotlin
Sort collection by multiple fields in Kotlin

Let's say I have a list of People which I need to sort by Age first and then by Name. …

kotlin