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
  • l

    Lukasz Kalnik

    02/06/2022, 2:24 PM
    I'm trying to get my
    Application
    class to extend a
    fun interface ImageLoaderFactory
    (from Coil). However I get the following error:
    Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option
    I have
    kotlinOptions.jvmTarget = "11"
    .
    g
    e
    • 3
    • 4
  • r

    rkeazor

    02/06/2022, 10:27 PM
    Hey is overriding a virtual fun with a reified type a bad idea?
    • 1
    • 1
  • s

    Subramanian Iyer

    02/07/2022, 4:30 PM
    https://developer.android.com/reference/kotlin/org/json/JSONObject. I'm trying to use a public method of this class as follows:
    fun getSource(inp: JSONObject, key: String): String{
        return JSONObject(inp.getString("_source")).optString(key)
    }
    My ide is saying that the public methods getString and optString are unresolved references. Anyone know what the issue might be?
    f
    s
    • 3
    • 8
  • v

    Vahalaru

    02/08/2022, 4:24 AM
    Hey guys when using compose, viewmodel, and hilt. What would be the best way to pass an argument from the viewmodel to a repository? On a click on list the ID of item is passed to the details viewmodel. But in my repository I need to use that ID to retrieve the recipe
    s
    • 2
    • 4
  • t

    Thanh Vu

    02/08/2022, 10:01 AM
    If you are using ListAdapter, what will you do when you want to change a property of model and notify file UI change? For example: when tapping an item change it ’s background Mine way: I’m will submit new list to adapter but not enough, it change the model in current list but UI not change yet, so I need to make model extend from
    BaseObservable
    and call
    notifyChange
    function
    :not-kotlin: 1
    j
    o
    • 3
    • 5
  • e

    edward

    02/08/2022, 5:23 PM
    What do people recommend for parsing JSON these days?
    r
    l
    +6
    • 9
    • 19
  • p

    Philip Dukhov

    02/10/2022, 3:48 AM
    I can place kotlin code both in
    src/kotlin
    and
    src/java
    , what are the benefits in using
    src/kotlin
    ? I guess it's easier to process, but I wan't being able to found any details.
    a
    a
    v
    • 4
    • 6
  • a

    Arash Rostami

    02/10/2022, 9:25 AM
    https://docs.google.com/spreadsheets/d/1SV7fjOe5KC42PrCx3F-vjrKLJWfiDpO-wSOGJfrJMBM/edit?usp=sharing [12:51 PM] https://docs.google.com/document/d/1VcHipouriAJVrMgGiPKBAF9-0tl-oil4pG647-aS0rg/edit?usp=sharing [12:53 PM] https://docs.google.com/presentation/d/1fxpYKgD8pbG__AE7vQbNohCLfsg-7ndA76H_WIFakFk/edit?usp=sharing
    :not-kotlin: 8
    👀 2
    👍 1
    😂 2
    t
    • 2
    • 1
  • s

    Sergio C.

    02/10/2022, 12:43 PM
    Hi, With the new Kotlin feature Prototype of Context Receivers how can we create an extension function for this nesting and make it just one line? I've seen something online but I lost the link.
    viewLifecycleOwner.lifecycleScope.launch {
        viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
            locationProvider.locationFlow().collect {
                // New location! Update the map
            }
        }
     }
    s
    • 2
    • 8
  • p

    Patrick Kellison

    02/11/2022, 12:59 AM
    Is it necessarily better or "safer" to call shared prefs from an IO dispatcher?
    f
    b
    • 3
    • 6
  • n

    Nick Shv

    02/11/2022, 2:23 AM
    Hi everyone, how to change clickable area for image in compose? I want it to be rounded
    j
    • 2
    • 1
  • a

    Arash Rostami

    02/11/2022, 8:29 AM
    dose any one know about android studio bumblebee adding safe Arg plugin the old plugin dosent work for some resion
    :not-kotlin: 3
    c
    i
    • 3
    • 3
  • m

    Milan Vadhel

    02/11/2022, 9:12 AM
    Is there any specific channel to ask CICD related questions?
    k
    t
    • 3
    • 7
  • o

    oday

    02/11/2022, 8:01 PM
    I pulled in a project for Apollo GraphQL, a starter Android app, it had build.gradle.
    kts
    for project and module, and settings.gradle.
    kts
    which made the formatting and structure of these files different and …weird than what I’m used to what’s the difference between one with that extension and one without that extension
    e
    • 2
    • 2
  • a

    Ahmad Dudayef

    02/12/2022, 1:42 AM
    Hi everyone, I try to implement StateFlow in viewmodel, but i confused how to add Loading state, i try to follow official documentation https://developer.android.com/kotlin/flow/stateflow-and-sharedflow, but i think it's just show state success and error, my question is how to add loading state using StateFlow in viewmodel ?
    s
    t
    • 3
    • 2
  • a

    Adib Faramarzi

    02/12/2022, 7:15 AM
    Is there any way to omit the
    kotlin.
    from
    kotlin.runCatching { ... }
    ? I always have to import the second option if I want the shorter one.
    c
    p
    a
    • 4
    • 28
  • m

    Madhav Budhiraja

    02/13/2022, 1:17 AM
    Hey there, hope you are doing well. I was making this app in Kotlin and while setting up themes I encountered a strange situation. I am using the theme,
    Theme.MaterialComponents.DayNight.DarkActionBar
    and when I set the layout in action bar through
    supportActionBar?.displayOptions = androidx.appcompat.app.ActionBar.DISPLAY_SHOW_CUSTOM
    supportActionBar?.setCustomView(R.layout.action_bar_textview)
    it worked fine in light mode but in dark mode it is showing these black rectangled corners as in these screenshots. Any workaround for this?
    :not-kotlin: 6
    t
    • 2
    • 2
  • a

    Arash Rostami

    02/13/2022, 7:18 AM
    Bottom Navigation Design hi every one as you can see my bottom navigation work compelitly fine but I cant see the icon on design what can I do about this problem?
    :not-kotlin: 11
    t
    • 2
    • 2
  • y

    Yacov Rosenberg

    02/14/2022, 6:25 PM
    When building modules in the app that will work like Libraries and maybe will be used in more than one app. Do you guys consider a good or bad practice to use a DI framework like coin in those modules?
    z
    j
    m
    • 4
    • 7
  • v

    Vivek Modi

    02/14/2022, 10:17 PM
    Hey I am working in Android kotlin. I have response data, which I want to filter and extract data according. My Response look like this. Inside my response there is three field strength, quantity and subscription. First Block in for strength, second block is for quantity and third block is for subscription. I will explain in more details. For example I want to filter all subscription value who has 25 , 50 and 75 and their value of quantity and subscription are respectfully from the response. Note subscription value is in repoonse is hard code. In real response it will more than 3 categories. I am thinking to use Tree or Graph data structure, but I am not 100% sure. I am doing correct or not. Is there any idiomatic kotlin way to achieved this. I want code to be Performance optimisation, speed, memory etc. I'll send these filter list to RecylerView and will manage to show like below image. Can someone guide me how to filter list through response. Thanks
    l
    d
    • 3
    • 5
  • j

    Jrichards1408

    02/15/2022, 10:03 AM
    Hiya, has anyone ever converted a PDF file to a image file(png or jpg) in code?
    :not-kotlin: 5
    g
    • 2
    • 3
  • a

    An Tran

    02/16/2022, 6:37 AM
    Hi guys, anyone doing exoplayer fullscreen button with jetpack compose ?
    :not-kotlin: 4
    c
    • 2
    • 1
  • a

    Alderson Elliot

    02/16/2022, 7:52 AM
    I have turned off the firewall but still get
    Connection refused
    :thread-please: 4
    :not-kotlin: 1
    k
    • 2
    • 2
  • i

    izyaboi

    02/16/2022, 10:40 AM
    i`ve one question about corutine testing? is there a way to test "Room Transactions" ? i used a lot of solutions but noting work . I want a test method "insertAndget()" that calls a transaction(inserAndUpdate) and after that call a query to get this inserted data to assert. What i get at the moment is not completed data strucure with missing data . i use "runTest" and in that fun i call the tranaction and after that i call my query.
    z
    • 2
    • 1
  • д

    Дмитрий Цывцын

    02/16/2022, 1:08 PM
    Hi guys! I created a simple Android lib to determine the location of the user https://github.com/KiberneticWorm/locsimple
    c
    • 2
    • 1
  • v

    Vivek Modi

    02/16/2022, 3:59 PM
    Hey I am sorting my reponse throught
    sortedWith
    +
    compareBy
    is any other way in kotlin to do that which better in performance, speed, memory management etc.
    val list = getUnSortedDataList()
    
    val sortedList = list.sortedWith(
        compareBy<ProductVariant> {
            it.strength?.toInt()
        }.thenBy {
            it.quantity?.toInt()
        }
    )
    data class ProductVariant(
        val strength: String? = null,
        val quantity: String? = null,
        val subscription: String? = null
    )
    m
    z
    b
    • 4
    • 11
  • s

    SooYoung

    02/16/2022, 5:27 PM
    The following code shows “Inappropriate blocking method call” warning. Can someone explain the reason for the warning and share some way to fix it?
    override suspend fun write(data: ByteArray) = withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
        context.openFileOutput(fileName, Context.MODE_PRIVATE).use {
            it.write(data)
        }
    }
    c
    g
    • 3
    • 11
  • r

    Ryan Flynn

    02/16/2022, 7:21 PM
    Is there any --Kotlin-- I need to add to ensure that Home remains clickable and navigable? Or could someone point me to some resources that might explain why this is happening?
    :not-kotlin: 2
    z
    • 2
    • 3
  • f

    Fabrizio Scarponi

    02/16/2022, 8:54 PM
    Hi there, I'm here to step up my kotlin specialization! I have a lot of questions to post! but for now, I'm looking for a good example of to how use properly ktor client response validation... can some one post me something? Thanks!
    c
    • 2
    • 2
  • v

    Vivek Modi

    02/17/2022, 11:17 PM
    Hey I am working in android kotlin. I am creating tree data structure and populate data in each level of root in different reyclerview. Now I want to set set default value. I have one Id and want to match that value with my list. I successfully create a tree but unfortunately I am not getting idea how to set default value. Can someone guide me. How to achieve this. My Project Link
    :not-kotlin: 2
    g
    • 2
    • 4
Powered by Linen
Title
v

Vivek Modi

02/17/2022, 11:17 PM
Hey I am working in android kotlin. I am creating tree data structure and populate data in each level of root in different reyclerview. Now I want to set set default value. I have one Id and want to match that value with my list. I successfully create a tree but unfortunately I am not getting idea how to set default value. Can someone guide me. How to achieve this. My Project Link
:not-kotlin: 2
https://stackoverflow.com/q/71166495/11560810
If you need more details please read above question. Thanks
g

gildor

02/18/2022, 3:09 AM
It doesn’t look related on Kotlin somehow
v

Vivek Modi

02/18/2022, 8:18 AM
But you can give an idea
View count: 3