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

    Shabinder Singh

    09/21/2021, 4:21 PM
    Possible Kotlin Bug: Kotlin Extension Function (on Firebase Transaction) is Not Being Recognized: See Attached Images, IDE is recognizing function which has transaction as a Parameter , but NOT another Extension Function Functions:
    suspend fun saveResponse( // WORKING & Recognizable
        uid: String,
        transaction: Transaction,
        response: JournalingResponseModel
    ): Result<Transaction>
    
    suspend fun Transaction.saveResponse( // Not being Recognized in another Extension Function
        uid: String,
        response: JournalingResponseModel
    ): Result<Transaction>
    ✅ 1
    e
    • 2
    • 3
  • s

    Shabinder Singh

    09/22/2021, 9:19 AM
    Hey 👋, Can someone link/ share a Generic HashMap Adapter for Moshi I think one might already exist instead of writing one of my own. Which I can add to Moshi Builder *To solve: `Platform java.util.HashMap> (with no annotations) requires explicit JsonAdapter to be registered`* I don't want to manually create Map TypeToken with key and value types for desrialization/ serialisation everytime I need.
    ✅ 1
    :stackoverflow: 1
    • 1
    • 1
  • t

    Tower Guidev2

    09/22/2021, 12:04 PM
    Hello, I thought Android Room supported Kotlin StateFlow as a return type within a @Dao can anyone confirm (or deny) this please? and identify what gradle version contians the chnage?
    s
    o
    • 3
    • 4
  • j

    Jitendra Kumar

    09/22/2021, 1:51 PM
    Hi , why can't i
    import java.io.File
    please ? My environment : ./gradlew -version
    ------------------------------------------------------------
    Gradle 7.0.2
    ------------------------------------------------------------
    Build time:   2021-05-14 12:02:31 UTC
    Revision:     1ef1b260d39daacbf9357f9d8594a8a743e2152e
    Kotlin:       1.4.31
    Groovy:       3.0.7
    Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
    JVM:          11.0.12 (Oracle Corporation 11.0.12+8-LTS-237)
    OS:           Mac OS X 11.5 x86_64
    m
    w
    • 3
    • 3
  • a

    Aman Kapoor

    09/22/2021, 3:12 PM
    Hi, do anyone have any idea about screen recording? MediaProjectionManager & VirtualDisplay.
    :not-kotlin: 2
    :stackoverflow: 2
    z
    • 2
    • 2
  • j

    JungIn Choi

    09/23/2021, 6:41 AM
    Hi, I have a question related to ANR & firebase. What I want is to diagnose ANR in production app, and send an alert with slack bot. I use Firebase crashlytics but somehow it didn’t send any alert related to ANR.. (Other alerts came fine..) 1. Is it true that ANR is not being caught in Firebase Crashlytics? 2. How do we trace ANR in production..? Is it possible to
    diagnose ANR in production app, and send an alert with slack bot
    ?
    :not-kotlin: 4
    l
    • 2
    • 1
  • c

    Christoffer Niska

    09/23/2021, 8:09 AM
    Hello all, 👋🏻 My name is Christoffer and I am a fullstack developer from Helsinki, Finland. I am currently working on an Android app that uses Compose. Even though TypeScript is my main tool of trade I have worked on a couple of Kotlin projects during the past year and I really love writing Kotlin. EDIT: Moved my question to #compose
    s
    • 2
    • 2
  • c

    Carsten Hagemann

    09/23/2021, 11:25 AM
    Hello there, I want to use kotlin's 1.5.30 feature
    jvmToolchain
    in my android project, but it doesn't seem to work at all. I have tried to include it, but it just gave errors that it couldn't find the command (in gradle speek). Did anyone here made it work?
    e
    g
    • 3
    • 12
  • m

    maniya anklesh

    09/24/2021, 4:56 AM
    can anyone tell me how can i create vertical view pager in jetpack compose?
    c
    • 2
    • 1
  • m

    Milan Vadhel

    09/24/2021, 10:38 AM
    Any one know how to call api in every 5 second using kotlin coroutine?
    c
    c
    • 3
    • 8
  • s

    Slackbot

    09/24/2021, 11:20 AM
    This message was deleted.
    :not-kotlin: 1
    🕹️ 1
    👀 1
    c
    • 2
    • 1
  • r

    Roy Owor

    09/24/2021, 5:37 PM
    Hell this is embarrassing but I need help. am failing to assign a string as as the first item using listOf
    var myString = "1234567"
    val myListOfStrings = listOf(myString)
    e
    • 2
    • 4
  • j

    Johnny

    09/25/2021, 12:39 AM
    Struggling to understand this. Does anyone know what the syntax at line 2 means? And why the input is
    SharedPreferences.Editor.()
    I get the extension function is accepting a lambda with input
    SharedPreferences.Editor.()
    but what does
    .()
    mean?
    private fun SharedPreferences.edit(func: SharedPreferences.Editor.() -> Unit) {
         val editor = edit()   // 1
         editor.func()         // 2
         editor.apply()        // 3
     }
    This is the code that uses the extension function
    val sharedPref = requireActivity().getPreferences(Context.MODE_PRIVATE)
    sharedPref.edit {
        putBoolean("hello", true)
    }
    e
    j
    • 3
    • 2
  • s

    Somesh

    09/25/2021, 9:11 AM
    I created this project to learn MVVM with Clean Arch (and to try out new tech). Can someone take a look & give me feedback? Any big mistake while following the clean-arch? Here is the project link: https://github.com/TheSomeshKumar/Clean-MVVM-Playground
    j
    • 2
    • 2
  • k

    Ketan Khunti

    09/25/2021, 3:29 PM
    Can anyone explain how to store image from our gallery to room database?
    🇳🇴 1
    👀 1
    :google: 1
    :not-kotlin: 3
    u
    j
    • 3
    • 17
  • l

    Lilly

    09/25/2021, 10:06 PM
    Ho can I divide unsigned types with numeric places?
    val value: UInt = 137
    println("Value: ${value / 10F}") // Does not work
    I can't find any hint how to the division. The result should be 13.7
    e
    c
    • 3
    • 7
  • j

    Johnjake Talledo

    09/26/2021, 6:04 PM
    Just would like to ask guys, is it good to use 
    anti pattern architecture
     with coroutines or 
    clean architecture
    ? As my concern on using clean arch is that it will add another layer, classes, callbacks and observable/collector. Also I am using paging3 library adding another layer might not be a good idea.
    🇳🇴 2
    k
    c
    • 3
    • 10
  • j

    jean pokou

    09/26/2021, 6:34 PM
    Hi anybody know how force ktlint to keep a line after a class declaration and the first property
    j
    c
    • 3
    • 4
  • h

    Hovhannes

    09/27/2021, 6:09 AM
    Hello, how can we get response body from API using Coroutines without sorting? Gson sorts it. Thanks in advance.
    :not-kotlin: 3
    t
    c
    • 3
    • 3
  • a

    adjpd

    09/27/2021, 9:00 AM
    Anyone know if using kotlin instead of groovy for gradle is still slower than using groovy for gradle? I've read a few articles on the internet saying so.
    :yes: 2
    s
    c
    • 3
    • 6
  • b

    Bijon Desai

    09/27/2021, 4:55 PM
    A common knowledge question around using implicit getter/setter in kotlin. I am writing a boolean that would return true/false based on enum of a particular kind. Is an assignment preferred in this case or a get() method? I am familiar with using get() as it looks good and provides a clear definition of the variable. Please provide your comments on this. Below is the code snippet:
    val isFord: Boolean
        get() = carType == CarType.FORD
    vs:
    val isFord = carType == CarType.FORD
    e
    l
    k
    • 4
    • 12
  • i

    Ink

    09/28/2021, 8:08 AM
    Hi guys. I sort by alphabetical order items in list by category name and it works but I want to have category "Other" always on the bottom. How Can I do that?
    enum class ItemCategory {
        ACCOUNT,
        CARD,
        OTHER,
        INVESTMENTS,
        LOAN
    }
    and then:
    items = itemList.sortedBy { it.category.name }.groupBy { it.category }
    a
    e
    • 3
    • 2
  • b

    Brian Stokes

    09/28/2021, 2:39 PM
    @Milan Vadhel Take a look at https://developer.android.com/topic/libraries/architecture/coroutines#restart and see if that’s what you need.
    m
    • 2
    • 1
  • s

    Susheel

    09/28/2021, 4:10 PM
    Does Kotlin have a limit on the number of parameters you can have in a data class? I was looking for info on this in the official documentation but didn't find anything.
    u
    e
    • 3
    • 2
  • m

    Matthew Laser

    09/28/2021, 7:22 PM
    hey all - I'm interseted in using KotlinPoet to generate some code around some Android libraries. The kotlinpoet itself seems really straightforward and easy to understand, but the docs on the site don't really seem to cover actually how to insert KotlinPoet into a build lifecycle. I found a stackoverflow question regarding custom gradle tasks, but I thought I'd ask if anyone here is aware of best practices/approaches when it comes to generating your own code.
    e
    • 2
    • 22
  • a

    andodeki

    09/29/2021, 5:33 AM
    I am using jetpack and I need to use my view model there as viewModel: HomeViewModel = hiltViewModel() but the hiltViewModel() is giving an error as Unresolved references
    a
    • 2
    • 10
  • t

    Tin Tran

    09/29/2021, 7:30 AM
    Hi! This block of code has
    inappropriate blocking method call
    warning. Does anyone know why?
    CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO>).launch {
        try {
            network.socketFactory.createSocket().use {
                it.connect(InetSocketAddress("8.8.8.8",53),1500)
                validNetworks.add(network)
                checkNetwork()
            }
        }
        catch (e:Exception){
            Timber.e(e)
        }
    }
    n
    e
    b
    • 4
    • 5
  • m

    Matthew Laser

    09/29/2021, 3:55 PM
    is anyone aware if it's possible to depend on the android SDKs indepently without using the
    android
    or android library plugins (just via the
    dependencies
    gradle block)? trying to do something with the android lib with KSP and running into trouble
    t
    a
    • 3
    • 4
  • r

    Rajput Art Studio

    09/29/2021, 3:55 PM
    Hello friends anyone know how integrate websocket in android with coroutine.any example then please help me
    r
    j
    • 3
    • 2
  • m

    Milan Vadhel

    09/30/2021, 7:12 AM
    Hello Friends , I have one task in which i want to start the scheduler for particular time. Scenario : When the sale is on for 2 hours let's say for 10 : 00 AM to 12 : 00 PM, i want to notify the user for sale is started and also update one popup for continues given time. Once the sale if off on 12:00 PM, the popup should be dismiss. Any one have idea how to handle this approach?
    :not-kotlin: 1
    m
    z
    i
    • 4
    • 7
Powered by Linen
Title
m

Milan Vadhel

09/30/2021, 7:12 AM
Hello Friends , I have one task in which i want to start the scheduler for particular time. Scenario : When the sale is on for 2 hours let's say for 10 : 00 AM to 12 : 00 PM, i want to notify the user for sale is started and also update one popup for continues given time. Once the sale if off on 12:00 PM, the popup should be dismiss. Any one have idea how to handle this approach?
:not-kotlin: 1
m

Minhaj

09/30/2021, 7:15 AM
Hello. for scheduling notification you can use AlarmManager.
m

Milan Vadhel

09/30/2021, 7:22 AM
Yes, But in my case the whenever the sale is on the notification will comes in from backend and i can post the notification.
z

Zun

09/30/2021, 11:01 AM
No idea how to do this reliably with data messages but alternatively you could let the user know the deal is expired in-app when they click the notification
m

Milan Vadhel

09/30/2021, 11:28 AM
Ok
i

Igor Brishkoski

09/30/2021, 1:39 PM
Do you control the backend? You can send a silent notification to the app to dismiss the sale notification.
m

Milan Vadhel

10/01/2021, 4:50 AM
@Igor Brishkoski Thank you for your reply, I know about the silent notification but i don't want to dismiss the notification. In our design, there is one screen is showing the label which indicates that the sale is live. Now if i user had already opened the screen which call the API for sale,after that i want to get the real time update for sale if off which ultimately hide the label of the sale.
Like i want to implement something like background worker that continuously check the sale is expired or not if yes then it will update me.
View count: 8