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

    Sudhir Singh Khanger

    07/03/2021, 8:51 AM
    A. If a
    LiveData
    object returns a non-null type would it at all trigger an observer's
    onChange()
    if there is no data to be served?
    val someLiveData: LiveData<List<String>> = ...
    val someObserver = { someValue: String ->
        // Will this return only if there is non-null data in someLiveData
    }
    B. Same case as above except the observer class expects a nullable type. So if
    LiveData
    returns non-null type but the observer object expects a nullable type then would we get a null value when there's nothing to be returned?
    val someLiveData: LiveData<List<String>> = ...
    val someObserver = { someValue: String? ->
       // Will this return null value from a non-null LiveData
    }
    a
    • 2
    • 2
  • r

    Robert Munro

    07/04/2021, 12:05 AM
    i seem to have managed to break
    :app:compileDebugUnitTestKotlin
    file or directory '/Users/robmunro/repos/personal/cuer/cuer/app/src/testDebug/kotlin', not found
    file or directory '/Users/robmunro/repos/personal/cuer/cuer/app/src/testDebug/java', not found file or directory '/Users/robmunro/repos/personal/cuer/cuer/app/src/testDebug/java', not found file or directory '/Users/robmunro/repos/personal/cuer/cuer/app/src/testDebug/kotlin', not found file or directory '/Users/robmunro/repos/personal/cuer/cuer/app/src/testDebug/java', not found file or directory '/Users/robmunro/repos/personal/cuer/cuer/app/src/testDebug/java', not found Transforming YouTubeAndroidPlayerApi.jar with JetifyTransform Transforming YouTubeAndroidPlayerApi.jar with IdentityTransform Transforming YouTubeAndroidPlayerApi.jar with JetifyTransform Transforming YouTubeAndroidPlayerApi.jar with IdentityTransform Using Kotlin/JVM incremental compilation file or directory '/Users/robmunro/repos/personal/cuer/cuer/app/src/test/kotlin', not found file or directory '/Users/robmunro/repos/personal/cuer/cuer/app/src/test/kotlin', not found file or directory '/Users/robmunro/repos/personal/cuer/cuer/app/src/test/kotlin', not found i: found daemon on port 17524 (224945 ms old), trying to connect i: connected to the daemon Options for KOTLIN DAEMON: IncrementalCompilationOptions(super=CompilationOptions(compilerMode=INCREMENTAL_COMPILER, targetPlatform=JVM, reportCategories=[0], reportSeverity=2, requestedCompilationResults=[0]kotlinScriptExtensions=[kt, kts, java, java, java]), areFileChangesKnown=false, modifiedFiles=null, deletedFiles=null, workingDir=/Users/robmunro/repos/personal/cuer/cuer/app/build/kotlin/compileDebugUnitTestKotlin, multiModuleICSettings=MultiModuleICSettings(buildHistoryFile=/Users/robmunro/repos/personal/cuer/cuer/app/build/kotlin/compileDebugUnitTestKotlin/build-history.bin, useModuleDetection=true), usePreciseJavaTracking=trueoutputFiles=[/Users/robmunro/repos/personal/cuer/cuer/app/build/tmp/kotlin-classes/debugUnitTest, /Users/robmunro/repos/personal/cuer/cuer/app/build/kotlin/compileDebugUnitTestKotlin]) AAPT2 aapt2-7.0.0-beta04-7396180-osx Daemon #0: shutdown <============-> 98% EXECUTING [4h 43m 44s]
    IDLE
    IDLE
    IDLE
    :app:compileDebugUnitTestKotlin
    :thread-please: 2
    c
    • 2
    • 2
  • m

    Maku Mazakpe

    07/04/2021, 8:06 AM
    a
    c
    +5
    • 8
    • 10
  • q

    QvK23

    07/05/2021, 1:18 AM
    Hey guys. I had that code
    @Synchronized
    fun abc() {
    // do some heavy tasks in multiple threads
    }
    In the document `@Synchronized`is thread safe annotation but I wonder that Should I use multiple thread operations inside function
    abc()
    ?
    g
    • 2
    • 2
  • s

    Sololo

    07/05/2021, 6:33 AM
    Can someone invite me to the AV channel?
    :not-kotlin: 2
    g
    • 2
    • 1
  • d

    Derek Ellis

    07/05/2021, 1:25 PM
    Presumably it would be unsafe to launch a coroutine using
    lifecycleScope
    in an activity's
    onDestroy()
    since the scope only spans until
    onDestroy()
    is called, right? What would be a suitable alternative to launch a coroutine to do some kind cleanup job that shouldn't be immediately canceled when the activity is destroyed?
    MainScope
    ?
    b
    • 2
    • 1
  • e

    Edidiong Aligve

    07/05/2021, 2:46 PM
    Hey guys, I need help. I am new to kotlin, what is the best way to store authentication token for a user in an app.
    :not-kotlin: 6
    b
    d
    h
    • 4
    • 3
  • j

    Juango

    07/05/2021, 7:06 PM
    Hi everyone, Does anyone have trouble importing "import androidx.compose.material.LocalContentAlpha" or maybe there is another way to implement
    CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
        Text("3 minutes ago", style = MaterialTheme.typography.body2)
    }
    g
    • 2
    • 1
  • v

    Vivek Modi

    07/06/2021, 9:01 AM
    i have string 
    <string name="data">%1$s / %2$s</string>
     i pass
    varargs
    in function like that
    fun getText(varargs text: String){
    	getString(R.string.data,text)
    }
    I called function
    getText("1" ,"2")
    It gives error 
    E/AndroidRuntime: FATAL EXCEPTION: main
      
    Process: com.vivek, PID: 5126
      
    java.util.MissingFormatArgumentException: Format specifier '%2$s'
        
    at java.util.Formatter.format(Formatter.java:2529)
        
    at java.util.Formatter.format(Formatter.java:2459)
        
    at java.lang.String.format(String.java:2911)
    b
    • 2
    • 2
  • v

    Viral Thakker

    07/06/2021, 11:32 AM
    Hi, Can anyone give me and example of using Channel with suspendCancellableCoroutine, for observing firebase document updates
    m
    • 2
    • 9
  • h

    haris mehmood

    07/07/2021, 5:20 AM
    hi, Best sdk for video calling in android for kotlin?
    :not-kotlin: 4
    s
    d
    • 3
    • 4
  • j

    Jørgen Heinsen

    07/07/2021, 9:38 AM
    Hi, I am having some problems with Hilt dependency injection. If I clean the project and then build, it builds just fine. But gives me ‘Unresolved reference’ on a bunch of my injected view models if I change anything in my activities/fragments and try and build again without cleaning. I have tried all different kinds of configurations in my gradle files, to no avail, me configuration looks like this:
    c
    m
    • 3
    • 7
  • n

    Nitish Sharma

    07/07/2021, 9:43 AM
    Hi, I am trying to fetch JSON data from an API in my kotlin android project. I tried researching about it but was unable to find a direct and easy method. Can anyone help me regarding the same? I am trying to get the City Name and Temperature only.
    v
    m
    +3
    • 6
    • 5
  • p

    Pavlo Zoria

    07/07/2021, 12:28 PM
    Hi guys! I found this issue while using Koin with JetpackCompose and create feature request on github. We can discuss it here to be more productive
    p
    • 2
    • 1
  • m

    Maku Mazakpe

    07/08/2021, 4:02 PM
    Hey guys, I have an app that has nested nav graph navigation setup. The root host seems to be setting a global theme for the rest of the graphs. E.g a theme set in the root navs activity is set in all other nav graphs activities. Has any one faced this issue and how did they go about solving it?
    :not-kotlin: 6
    a
    • 2
    • 2
  • p

    Peter Mandeljc

    07/08/2021, 7:00 PM
    would it be possible, to start activity for result (e.g. select file), if you only have context. I have a wild idea of making interactor/usecase that does that. Any ideas?
    class SelectFileUseCase @Inject constructor(
        @ApplicationContext private val context: Context
    ) {
        operator fun invoke(): Uri {
            val intent = Intent().apply {
                type = "file/*"
                action = Intent.ACTION_GET_CONTENT
                addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
            }
    
            context.startActivity(intent)
            
            // how to get result??
            context.registerReceiver(receiver, filter) // maybe?
        }
    }
    a
    i
    • 3
    • 4
  • f

    frankelot

    07/08/2021, 10:46 PM
    Is it possible to specify the underlaying
    Map
    implementation of
    mutableStateMapOf()
    ?
    z
    • 2
    • 3
  • h

    haris mehmood

    07/09/2021, 7:02 AM
    Hi, for location tracking in background which one is good ? Work Manager or Service or JobScheduler or something else?
    :not-kotlin: 3
    a
    d
    • 3
    • 7
  • y

    Yves Kalume

    07/09/2021, 11:51 AM
    Hi, Wich is the best way to use Hilt with Mavericks viewmodel ?
    :not-kotlin: 3
    a
    • 2
    • 1
  • m

    melatonina

    07/09/2021, 6:04 PM
    While I understand the need for limiting the discussion here to "Using Kotlin to build Android applications" (and I deleted my previous message - I'm sorry), in my experience, "Android United" and "Android Chat" are almost dead. I still get more help in the #android-dev IRC channel on libera.chat. StackOverflow is way more useful than all those sources together, even if the kind of interaction is different from a chat. I'll try the Discord server, in future.
    👍 3
    b
    • 2
    • 1
  • n

    Noushad Chullian

    07/10/2021, 2:32 PM
    does jetpack compose support kotlin compiler version 1.5.*??
    :yes: 2
    z
    • 2
    • 2
  • s

    spierce7

    07/10/2021, 3:51 PM
    So it looks like android can swap out dex files at runtime via the DexClassLoader. React Native allows downloading new code and swapping it out, which seems like a great way to force updates for an app. Why aren't their libraries for this on Android? This seems very useful. Is there something I'm not realizing?
    :not-kotlin: 3
    z
    e
    • 3
    • 11
  • j

    John O'Reilly

    07/11/2021, 9:30 AM
    Am using
    androidx.datastore:datastore-preferences:1.0.0-rc01
    and seeing occasional crashes in play console (stack trace in thread) but can't reproduce locally....just in case anyone else has encountered this.
    f
    • 2
    • 4
  • f

    FunkyMuse

    07/11/2021, 2:35 PM
    Hi everyone Today I've published an article about how you can protect your Android app from being tampered. You can check it out at https://funkymuse.dev/posts/android_anti_tampering/
    :not-kotlin: 3
    c
    e
    • 3
    • 8
  • h

    HUONG

    07/12/2021, 8:48 AM
    Hi there ! I want to create this, I try to explore some thing about Round ProgressBar Segment, but Im sill fail because some article is not detail. Anyone can help me. Im not good at CustomeView
    :not-kotlin: 8
    l
    • 2
    • 3
  • h

    Hovhannes

    07/12/2021, 2:27 PM
    Hello,  I want get the objects from users array from API using Moshi , but I get this error  'Expected BEGIN_ARRAY but was BEGIN_OBJECT at path $'. What mistake I made? Thanks in advance.
    {
      "users": [
        {
          "id": "1",
          "name": "Bill Roy",
        },
         {
          "id": "2",
          "name": "Ben Bush",
        },
        {
          "id": "3",
          "name": "Dan Fox",
        },
    
      ]
    }
    User.kt
    data class User(
        @Json(name = "id")
        val id: Int = 0,
        @Json(name = "name")
        val name: String = "",
        @Json(name = "users")
        val userList: List<User>
    )
    ApiService.kt
    interface ApiService {
        @GET("getUsers")
        suspend fun getUsers(): Response<List<User>>
    }
    :not-kotlin: 6
    c
    • 2
    • 2
  • a

    atanasi charle

    07/12/2021, 8:22 PM
    Hello guys!.. I need your help. I need to pass parameter to the composable inside sealed class. Below is the screenshot where there is RecommendedScreen(models = ) composable that needs a parameter. Can you guys tell how to do that?.
    z
    k
    q
    • 4
    • 11
  • a

    Abhishek K

    07/13/2021, 5:50 AM
    Does anyone know how to do like this Search in instagram and show images like this??? Images coming from server.
    :not-kotlin: 12
    u
    • 2
    • 4
  • m

    melatonina

    07/13/2021, 9:32 AM
    Android Studio 2020.3.1 Canary 15 supports databinding with StateFlow<T> in viewmodels. Does it support two-way databinding when the view property is also a StateFlow<T>? If now, why?
    g
    • 2
    • 37
  • r

    Rak

    07/13/2021, 11:20 AM
    Does anyone know if Jetpack compose will allow configuration-driven UI easier? I’m working on a white label app and there are some differences between brands.
    m
    • 2
    • 2
Powered by Linen
Title
r

Rak

07/13/2021, 11:20 AM
Does anyone know if Jetpack compose will allow configuration-driven UI easier? I’m working on a white label app and there are some differences between brands.
m

melatonina

07/13/2021, 11:25 AM
Any reason why you are not asking in the dedicated #compose channel?
r

Rak

07/14/2021, 8:09 AM
because I didn’t know it existed!
View count: 9