https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
android
  • j

    Juan Carlos Pazos

    02/18/2022, 12:10 AM
    Hi, do you know some public API that let not only retrieve data but post and delete too? I’m giving a course to students and we are actually made progress with Open Weather but I wand the know how to do all the CRUD operations. Thanks
    :not-kotlin: 5
    m
    t
    +1
    6 replies · 4 participants
  • v

    Vivek Modi

    02/19/2022, 2:21 PM
    Hey I am working in kotlin. I want to find index in which the variable value is true. I used MapIndex to find index of that value which is true. But I am using nesting mapIndex so may be there time complexity would be multiple. I need to improve that mapIndex logic to be more efficient in performance, speed, memory etc.
    2 replies · 1 participant
  • v

    Vivek Modi

    02/19/2022, 10:00 PM
    Hey I am learning atomic integer in kotlin. I want to know is there atomic integer swap value if current value is smaller than new value. For example AtomicInt 10 S*cenario 1*  new value is 5 and it changes to 5 because 5 is lower than 10 Scenario 2 new value is 20 it will not change the atomic value because 20 is greater than 10. Can we do this throught CompareAndSwap function?
    a
    e
    5 replies · 3 participants
  • n

    Noushad Chullian

    02/20/2022, 9:55 AM
    Hi, friends, I need help to make my app available for large screens. I am using jetpack navigation with fragments. can anyone help me?
    🇳🇴 1
    :not-kotlin: 12
    i
    c
    5 replies · 3 participants
  • t

    Tran Thang

    02/21/2022, 7:39 AM
    Hello everyone, Inside my app, I am given a Latitude and Longitude shipping address. And when the user presses a button, it opens the Google Map and directions from my location to the delivery location according to Latitude and Longitude. But now I also want to do the same thing for Chinese customers, And I see in China Baidu Map is replaced for GoogleMap, But I don’t know how to open deep link similar to google map, But this is my way of doing it but it is crashing, can someone help me to solve this problem DeepLink From Google:
    if (isIos) {
        return `comgooglemaps://?daddr=${lat},${lng}&directionsmode=driving`;
     } else {
      return `google.navigation:q=${lat},${lng}`;
     }
    My deeplink open Baidu Maps:
    `<baidumap://map/navi?location=39.940488,116.355425>`;
    Anyone please help me resolve this problem.
    :not-kotlin: 2
    z
    1 reply · 2 participants
  • c

    Chethan

    02/21/2022, 12:26 PM
    Does Boot completed broadcast works without launching application ?, here is my android manifest, I am not keeping activity LAUNCHER filter . I do not see broadcast receiver calls in boot completed
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.DownloadPOC">
        <activity
            android:name=".MainActivity"
            android:exported="true">
           
        </activity>
    
        <!-- Declaring broadcast receiver for BOOT_COMPLETED event. -->
        <receiver
            android:name=".DeviceBootUpReceiver"
            android:enabled="true"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
    
    </application>
    :not-kotlin: 6
    p
    2 replies · 2 participants
  • e

    Enrico Saggiorato

    02/21/2022, 5:38 PM
    Hi, I know that this sounds like a dumb question, but I don't really get it. When using BlendMode, which color is source and which is destination? I'm getting some weird behavior, I think I misunderstood
    :not-kotlin: 6
    z
    1 reply · 2 participants
  • p

    Prapoorn Babu Vupupla

    02/22/2022, 3:33 AM
    Hi, I had a doubt, how to use live data to set and get value from the camera intent and pass the same to other class.
    :not-kotlin: 6
    c
    1 reply · 2 participants
  • v

    Vivek Modi

    02/22/2022, 10:54 PM
    Hey I want to use custom comparator in priority queue in kotlin. I have data class Product.kt
    data class Product(val value: String? = null, val price: String? = null) {
        var priceInLong = price?.toLong()
    }
    I want to create a min heap where price value will be minimum. I am creating the object but it giving me some kind of error
    fun main() {
        var queue = PriorityQueue<Long> { p1: Product, p2: Product ->
            p1.priceInLong?.let {
                p2.priceInLong?.minus(it)
            }
        }
    
        val list = listOf(
            Product("1", "4.83"),
            Product("2", "4.53"),
            Product("3", "3.54"),
            Product("4", "3.66"),
            Product("5", "5.16")
        )
    }
    Error
    None of the following functions can be called with the arguments supplied.
    <init>((MutableCollection<out TypeVariable(E)!>..Collection<TypeVariable(E)!>?))   where E = TypeVariable(E) for    constructor PriorityQueue<E : Any!>(c: (MutableCollection<out E!>..Collection<E!>?)) defined in java.util.PriorityQueue
    <init>(Comparator<in TypeVariable(E)!>!)   where E = TypeVariable(E) for    constructor PriorityQueue<E : Any!>(comparator: Comparator<in E!>!) defined in java.util.PriorityQueue
    <init>(PriorityQueue<out TypeVariable(E)!>!)   where E = TypeVariable(E) for    constructor PriorityQueue<E : Any!>(c: PriorityQueue<out E!>!) defined in java.util.PriorityQueue
    <init>(SortedSet<out TypeVariable(E)!>!)   where E = TypeVariable(E) for    constructor PriorityQueue<E : Any!>(c: SortedSet<out E!>!) defined in java.util.PriorityQueue
    <init>(Int)   where E = TypeVariable(E) for    constructor PriorityQueue<E : Any!>(initialCapacity: Int) defined in java.util.PriorityQueue
    w
    a
    +2
    8 replies · 5 participants
  • t

    Tewogbade Oluwadamilare

    02/23/2022, 7:59 AM
    Where can I learn Kotlin for free please?
    g
    p
    3 replies · 3 participants
  • a

    Ali Akram

    02/23/2022, 8:43 AM
    Hi, can someone guide how to manage viewbinding in adapter incase we have two viewTypes of layouts
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        mContext = parent.context
    
        val binding = if (viewType == 0)
            VerOcfProductGroupLayoutBinding.inflate(
                LayoutInflater.from(parent.context),
                parent,
                false
            )
        else
            OcfProductGroupLayoutBinding.inflate(
                LayoutInflater.from(parent.context),
                parent,
                false
            )
    
        return ViewHolder(binding)
    
    }
    How to handling in
    onBindViewHolder
    ?
    :not-kotlin: 3
    p
    2 replies · 2 participants
  • a

    Ali Akram

    02/23/2022, 11:58 AM
    i didnt understand Not-Kotlin flag please explain ?
    m
    v
    +4
    13 replies · 7 participants
  • m

    Marc

    02/24/2022, 3:24 PM
    I want to add the flag
    -Xcontext-receivers
    in my android studio bumblebee Kotlin compilation flags but I can’t find where to set it. Anyone knows the place? thx
    m
    1 reply · 2 participants
  • a

    Advitiay Anand

    02/24/2022, 10:29 PM
    What Kotlin concepts are required or preferred for being adept at Android? I understand much of the new syntax (thanks to Kotlin Koans), and currently learning Coroutines and Flows. Should these suffice for making decent Android apps? Can I shift my focus solely on Android now?
    s
    a
    3 replies · 3 participants
  • o

    oday

    02/25/2022, 8:59 AM
    I have a weird question, how would it be possible or is it possible to write something or use some software that can show me all the screens of an app? I would run it for example and it would open and screenshot (or log) all the possible screens that exist in the project
    :not-kotlin: 1
    l
    3 replies · 2 participants
  • m

    Martijn Eschmeijer

    02/25/2022, 4:40 PM
    Hey all, Not a question, but a shameless plug (for a good cause!) The Kotlin Dev Day conference will take place in Amsterdam on May 19th. In the Johan Cruijff ArenA (Ajax football stadium) we will host 3 stages full of Kotlin, with both server-side and Android/mobile talks. Some highlights in terms of speakers: Hadi Hariri, James Ward, Andrey Breslav (not announced yet), Anton Arhipov, Marcin Moskala, Urs Peter, Liliia Abdulina. Find the full program and speakers here: https://kotlindevday.com It's a not-for-profit conference, which means that all profits will be donated to something that the community chooses. Voting will be done at the event 🙂 And yes, there are sponsors that cover some of the costs. Hopefully all the costs, so there is more money for charity, sustainability, diversity, supporting open-source initiatives, etc. We're very excited and we hope to bring the European Kotlin community together! Enjoy your weekend! 💰 Please be advised that early bird tickets are available until the end of the month. So next Tuesday 🙂
    💯 2
    a
    z
    6 replies · 3 participants
  • m

    Matthias Geisler

    02/25/2022, 8:29 PM
    Hey...in the light of the latest events in Ukraine...has anybody an overview if there are still active App Projects for Refugees? (Sorry I know it's not directly Kotlin related)
    💡 1
    a
    4 replies · 2 participants
  • k

    Kiki Abdullah

    02/27/2022, 4:46 AM
    I got this warning `This
    TypedArray
    should be recycled after use with `#recycle()`` after use
    obtainTypedArray
    for my array list. But when I try to call
    recycle()
    ,
    getResourceId()
    show
    unresolved reference
    error.
    z
    4 replies · 2 participants
  • a

    Android75

    02/27/2022, 3:35 PM
    Hi i think i am OT but my question is very simple. is there some server to use inside an application? Http server to comunicate with other application in lan ? maybe ktor?
    a
    1 reply · 2 participants
  • m

    Micko Cabacungan

    02/28/2022, 1:05 AM
    Is there a callback for compose
    animateSizeAsState
    that gets invoked when
    targetValue
    is not changed and so results with no animation happening, but still have a callback invoked
    a
    1 reply · 2 participants
  • s

    Solomon Tolu Samuel

    02/28/2022, 6:11 AM
    Hey guys, i am trying to receive location updates using this example https://conorsmith.dev/post/kotlin_flow_location_updates/ I found online. But I have no idea how to Provide the fusedLocationProviderClient to the viewModel, so I tried Providing this way:
    @Singleton
    @Provides
    fun ComponentActivity.FusedLocationProvider(): FusedLocationProviderClient{
        return LocationServices.getFusedLocationProviderClient(this)
    }
    But then I get this error:
    /Users/tolusolomon/AndroidStudioProjects/Link/androidLink/build/generated/source/kapt/debug/com/example/link/android/Application_HiltComponents.java:125: error: [Dagger/MissingBinding] androidx.activity.ComponentActivity cannot be provided without an @Inject constructor or an @Provides-annotated method.
      public abstract static class SingletonC implements Application_GeneratedInjector,
                             ^
          androidx.activity.ComponentActivity is injected at
              com.example.link.android.Di.AppModules.FusedLocationProvider($this$FusedLocationProvider)
          com.google.android.gms.location.FusedLocationProviderClient is injected at
              com.example.link.android.LocationBusiness(fusedLocationProvider)
          com.example.link.android.LocationBusiness is injected at
              com.example.link.android.Presentation.screen.Place.PlaceViewModel(locationBusiness)
          com.example.link.android.Presentation.screen.Place.PlaceViewModel is injected at
              com.example.link.android.Presentation.screen.Place.PlaceViewModel_HiltModules.BindsModule.binds(vm)
          @dagger.hilt.android.internal.lifecycle.HiltViewModelMap java.util.Map<java.lang.String,javax.inject.Provider<androidx.lifecycle.ViewModel>> is requested at
      dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.ViewModelFactoriesEntryPoint.getHiltViewModelMap() [com.example.link.android.Application_HiltComponents.SingletonC → com.example.link.android.Application_HiltComponents.ActivityRetainedC → com.example.link.android.Application_HiltComponents.ViewModelC]
    Any idea about how to provide the fusedLocationProviderClient to the ViewModel using Hilt? Thanks
    n
    3 replies · 2 participants
  • a

    Alexander Suraphel

    02/28/2022, 12:04 PM
    I want to create android app that reuses most of my web UI but with few native functionality. What is a good approach to seamlessly navigate between native screens and web ones? Is this a commonly solved problem? thanks
    z
    2 replies · 2 participants
  • s

    Sivan

    02/28/2022, 1:59 PM
    Trying to insert a list of items and Room is throwing the following error :
    error: Not sure how to handle insert method's return type.
    Kotlin version : 1.6.0 Room version : 2.4.2 Here is my DAO :
    @Dao
    interface UserDao {
       .....
    
        @Insert(onConflict = OnConflictStrategy.IGNORE)
        fun loadUsers(userCacheEntities: List<UserCacheEntity>): Long
    
       .....
    }
    :not-kotlin: 3
    t
    a
    4 replies · 3 participants
  • y

    Yevhen Railian

    03/01/2022, 8:06 AM
    I know that maybe you will ban me, but i can not keep silence. I am an android dev more than 9 years and i am in Ukraine. I want people from all over the world including Russia know about the crimes the Russian government and the Russian army commit in the Ukraine. On this video you can see a huge city Harkiv these days. they are civilians in the center of the city. Russians, stop this war. in this war you are not heroes.

    https://youtu.be/fbhDjN0jy8s▾

    https://youtu.be/P_RDqI_hX8Y▾

    NO WAR!!!
    VID_20220301_093215_408.mp4
    ❤️ 8
    ☮️ 13
    😱 1
    🇺🇦 29
    r
    v
    +2
    8 replies · 5 participants
  • s

    Slackbot

    03/01/2022, 8:41 AM
    This message was deleted.
    :not-kotlin: 2
    r
    1 reply · 2 participants
  • n

    Nick Shv

    03/01/2022, 1:03 PM
    How to add field to default existing request body (defined in client) in post request using retrofit?
    :not-kotlin: 2
    g
    1 reply · 2 participants
  • s

    Slackbot

    03/01/2022, 1:40 PM
    This message was deleted.
    m
    1 reply · 2 participants
  • i

    Iqbal Ahmed

    03/02/2022, 5:34 AM
    Suggestion Needed Should we use buildSrc for dependencies in 2022? or should we go with ext for versioning?
    p
    v
    +1
    11 replies · 4 participants
  • v

    Vivekpanchal64

    03/02/2022, 6:28 AM
    I have a database which is prepopulated with some tables which is working fine. I have prepopulated my db. like this
    Room.databaseBuilder(
            get(),
            AppDatabase::class.java,
            APP_DATABASE
             )
            .createFromAsset("app.db")
            .fallbackToDestructiveMigration()
            .build()
    the problem I am facing is that. when user adds his own data it got inserted correctly and displayed on my screen. when I move app to the background and remove it from there and reopen the application. I don't se my data and only the default data is present there. any help would be appreciated
    :not-kotlin: 2
    r
    2 replies · 2 participants
  • f

    Freedom

    03/02/2022, 5:05 PM
    Hello I just updated my Gradle and kotlin version and i realise the structure of project-level .gradle has changed and settings.gradle are there any docs explaining it usages ?
    g
    5 replies · 2 participants
Powered by Linen
Title
f

Freedom

03/02/2022, 5:05 PM
Hello I just updated my Gradle and kotlin version and i realise the structure of project-level .gradle has changed and settings.gradle are there any docs explaining it usages ?
g

Guilherme Cordeiro

03/02/2022, 5:10 PM
Usually gradle documentation is very good covering new feature releases and upgrade steps... At the risk of sounding redundant, did you take a look there? https://docs.gradle.org/current/userguide/upgrading_version_6.html
Specially at gradle 7.X there have been some root project level changes that might generate new warnings
f

Freedom

03/02/2022, 5:29 PM
wasn't too helpful
but thanks i really appriciate
thanks figured it out
View count: 2