Questions

Kotlin questions

Choose a question page, learn the concept, then test your understanding with a quiz.

Accessing Kotlin Extension Functions from Java

Learn how Kotlin extension functions are compiled and how to call them correctly from Java with clear examples and common pitfalls.

kotlinjavaextension-function

Add a Maven Repository URL in Gradle Kotlin DSL (build.gradle.kts)

Learn how to add Maven Central and a custom Maven repository URL in Gradle Kotlin DSL using build.gradle.kts syntax.

kotlingradlegradle-kotlin-dsl

Allow HTTP and HTTPS in Android 9 Pie with Network Security Configuration

Learn how Android 9 Pie handles cleartext HTTP traffic and how to allow HTTP and HTTPS safely using network security config.

kotlinjavaandroidandroid-9.0-pie

Android AlarmManager Example: Scheduling Tasks with AlarmManager

Learn how to use Android AlarmManager to schedule tasks, set alarms, and handle broadcasts with a simple beginner example.

kotlinjavaandroidalarmmanager

Android Data Binding in Kotlin: Fix Unresolved Reference Errors

Learn why Android Data Binding classes can be unresolved in Kotlin and how to configure generated bindings and fragments correctly.

kotlinjavaandroidandroid-databinding

Android FloatingActionButton Visibility and Restricted API Warnings in Kotlin

Learn why FloatingActionButton visibility can trigger a restricted API warning in Kotlin and when to use show(), hide(), or View visibility.

kotlinandroidandroid-9.0-pieandroid-jetpack

Android Foreground Service Notification Channels in Kotlin

Learn why startForeground fails on Android 8.1 and how to create a valid notification channel for foreground services in Kotlin.

kotlinandroidserviceandroid-notifications

Android Navigation Safe Args Directions Classes in Kotlin

Learn why Android Navigation Safe Args generates Args classes but not Directions classes, and how actions create type-safe navigation calls in Kotlin.

kotlinandroid-navigationandroid-jetpack

Android Room Main Thread Error: How to Run Queries Safely in Java/Kotlin

Learn why Room blocks database access on the main thread and how to fix it using background threads, executors, and async patterns.

kotlinandroidcrashandroid-studio-3.0

Android onBackPressed Deprecation: Modern Back Handling in Kotlin

Learn the alternative to deprecated onBackPressed() in Android using OnBackPressedDispatcher and OnBackPressedCallback in Kotlin.

kotlinandroidnavigationdeprecation-warning

AsyncTask Alternatives in Android: Replacing Deprecated AsyncTask with Executor and Handler

Learn how to replace deprecated AsyncTask in Android using Executor, Handler, and modern concurrency patterns for older codebases.

kotlinjavaandroidandroid-asynctask

Backward Ranges in Kotlin: Using downTo and step

Learn how to create backward ranges in Kotlin with downTo and step, why 100..1 is empty, and how to loop safely in descending order.

kotlinrange

Builder Pattern in Kotlin: How to Build Objects Idiomatically

Learn how to implement the Builder pattern in Kotlin, when to use it, and which Kotlin features often replace builders.

kotlindesign-patterns

Can You Extend a Data Class in Kotlin? Inheritance, Limits, and Better Alternatives

Learn why Kotlin data classes cannot be extended, what causes the component function clash, and which alternatives to use instead.

kotlininheritanceabstractdata-class

Check Whether a String Array Contains a Value in Kotlin

Learn how to check whether a Kotlin Array<String> contains a value using in, contains(), and any(), with examples and common mistakes.

kotlinarrays

Close the Virtual Keyboard in Jetpack Compose TextField

Learn how to hide the Android virtual keyboard after a Jetpack Compose TextField IME Done action using KeyboardActions and focus control.

kotlinandroidandroid-jetpack-composeandroid-input-method

Convert a Kotlin Array to Java varargs: Passing Arrays to Java Methods from Kotlin

Learn how to pass a Kotlin Array or ArrayList to a Java varargs method using the spread operator and type conversion.

kotlinjavainteropkotlin-interop

Create Anonymous Interface Instances in Kotlin with SAM Conversion

Learn how to implement a Java single-method interface in Kotlin using concise SAM conversion or an object expression, with examples and pitfalls.

kotlinjavalambdaanonymous

Create Arrays by Size in Kotlin: IntArray and Array

Learn how to create Kotlin arrays with a specified size, including IntArray for primitive integers and Array for objects.

kotlinjavaarraysarraylist

Custom Getters in Kotlin Data Classes

Learn how Kotlin property getters work in data classes, why primary constructor properties cannot use custom accessors, and safe alternatives.

kotlin

Page 1 of 9 - 162 questions

PreviousNext