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

    Maya Gorel

    08/02/2020, 4:39 AM
    Hi, do you have an example of customised spinner in kotlin (androidx)? I tried so many examples with no success…I need spinner with border and arrow
    w
    c
    • 3
    • 4
  • k

    Kulwinder Singh

    08/02/2020, 10:45 AM
    can we @Parcelize
    sealed class
    and pass it using safeArgs or Bundle ??
    d
    • 2
    • 1
  • s

    Sergio C.

    08/02/2020, 3:48 PM
    Why am I getting this error in android studio dsl file?
    Unresolved reference: getKotlinPluginVersion
    a
    • 2
    • 3
  • p

    Petar Marijanovic

    08/03/2020, 11:52 AM
    Hey 😄  I've created a small test for a product and would appreciate any feedback on it! Long story short: If you subscribe, each day, for the next 3 days, you will get a small, but interesting RxJava2 Puzzler (written in Kotlin) with a detailed explanation. You will either learn something new, or confirm your knowledge. https://mailchi.mp/631bd69d4410/smallengineer-rxjava2puzzlers-free After three days, there is a small survey just so I can gather feedback. Thanks, and tell me what you think!
    a
    • 2
    • 2
  • s

    Souhail Marghabi

    08/03/2020, 12:36 PM
    Hello everyone, I have a question regarding Library Modularization. I am working on an Android Library Project where I am trying to split the main library into multiple modules( core, registration/login modules, and other library modules) and then adding the multi module library as one to receiving apps. I read that there are limitations in adopting this approach, can anyone suggest how this can be best achieved? Thank you.
    b
    k
    • 3
    • 9
  • r

    Rooparsh

    08/03/2020, 2:10 PM
    Hello everyone I have been trying Kotlinx Serialization in an android project of mine. Is this issue quite common or what? I have a List of String as an object inside my data class. But when I try to parse it, I get stringified array. Following is the data class of my api
    @Serializable
    data class ApiError(
      @SerialName("error") val error: Error
    )
    
    @Serializable
    data class Error(
      @SerialName("code") val code: Int,
      @SerialName("timestamp") val timestamp: String,
      @SerialName("path") val path: String,
      @SerialName("method") val method: String,
      @SerialName("message") val message: List<String>
    )
    And this is the parsing logic:
    private fun ResponseBody?.toApiError(): ApiException {
      return ApiException(
        Json(
          JsonConfiguration(
            ignoreUnknownKeys = true,
            isLenient = true
          )
        ).parse(
          ApiError.serializer(), this?.charStream()
          ?.readText()
          .orEmpty()
        )
      )
    }
    But when I print the key
    message
    all I get is
    "[User not found.]"
    Am I missing here something ? I am using this dependency
    com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.5.0
    g
    • 2
    • 1
  • j

    jurajsolarml

    08/03/2020, 2:13 PM
    Hello, please help. Where can there be a mistake ? AS 4.0.1 Thanks
    v
    t
    • 3
    • 8
  • m

    Michael Friend

    08/03/2020, 6:24 PM
    Is the
    liveData
    coroutine builder suited for retrying/refreshing data loads or does everyone typically avoid it when you need that functionality? I’ve started using it recently to lazily load data when needed by the UI, but i cant come up with a clean way of using
    liveData
    while also being able to refresh the data (i.e. when coming back to the screen) or retry failed operations. Typically my ViewModels look something like:
    val data: LiveData<State<MyData>> = liveData {
        emit(Loading)
        try {
            emit(getData())
        catch (e: SomeEx) {
            emit(Error(e))
        }
    }
    suspend fun getData(): MyData {...}
    But with this i have no way of actually retrying the operation and emitting to the LiveData again if it fails. And in the cases i need to update the data on user events like a refresh button or returning to the screen I’m stuck with the stale data.
    o
    • 2
    • 5
  • w

    Will Nixon

    08/04/2020, 12:38 PM
    Dumb question - but what’s the equivalent of iCloud on Android? Is there a way for a user to have app data sync across multiple devices? If so, is it via an account that you can expect all/most users to have nowadays? (edited)
    o
    j
    +2
    • 5
    • 9
  • a

    amar_1995

    08/04/2020, 1:16 PM
    I am logging out a user and shows the login screen. While logging out I want to clear all the data from room db. Logout is working fine but database is not getting cleared. I think the issue is occuring because the db clear function is getting called from viewmodel and viewmodel lifecycle get destroyed after moving to login screen. So how can I handle this issue ? Or what is best way to handle logout flow ?
    r
    • 2
    • 1
  • k

    Koya Sivaji

    08/04/2020, 3:42 PM
    I am using Kotlinx serializer for serializing/deserializing of data classes with retrofit. I need to skip the null values from serialization, but I couldn’t find the way to do that here is my data class
    @Serializable
    data class Attributes(
        val home: String? = null,
        val room: String? = null,
        val announcement: Int? = null,
        val push_notification_enabled: Int? = null
    )
    when I called Attributes().serialize() , the resulting json as below
    "attributes":{
          "home":null,
          "room":"null",
          "announcement":null,
          "push_notification_enabled":null
       }
    what is expected is
    "attributes":{}
    Note: serialize() is an extension function as below
    inline fun <reified T: Any> T.serialize(): String {
        return Json.stringify(T::class.serializer(), this)
    }
    Basically I want to exclude all null params from serialization. I tried with by setting
    JsonConfiguration( encodeDefaults = false)
    , but still resulting json includes
    null
    fields from data class. Anyone has idea of how to do that
    o
    j
    • 3
    • 2
  • a

    Antoine Gagnon

    08/05/2020, 4:35 PM
    Hi everyone! I’m having some issues figuring out how to use a
    Fragment
    implementation both in the “normal” way (embedding it in an activity for instance) and also be able to display it as a modal. I know it’s pretty easy with a
    DialogFragment
    implementation to display it as a modal, but I wanted to know if it’s possible to also display a
    Fragment
    as a modal, or maybe wrap it in a
    DialogFragment
    ?
    ✔️ 1
    i
    d
    c
    • 4
    • 5
  • j

    Jonathan Padilla

    08/06/2020, 12:46 AM
    Hey everyone I'm working on a kotlin, firebase android chat app. Anyone have any tips on adding attachment functionality like posting an image to a chat conversation and having it displayed to both parties? I already have real time messaging working, I can't figure out file attachment sharing at all and I've looked online for guides but to no avail. If anyone can point me a good direction thank you! If not then that's fine thanks for reading this!
    z
    h
    • 3
    • 3
  • j

    Joey

    08/06/2020, 1:28 AM
    Anyone tried sign up with facebook function? I can only see login with facebook from their documents.
    :stackoverflow: 2
    i
    • 2
    • 1
  • g

    george

    08/06/2020, 6:05 AM
    hello, how does android decide if it has access to internet when you connect to wifi? i want to trick it that it has the connection, otherwise Downloadmanager doesnot download files on my VPN :(
    :stackoverflow: 2
    g
    • 2
    • 9
  • a

    amar_1995

    08/06/2020, 12:39 PM
    I am using
    WorkManager
    with constraint
    Network.Connected
    but it only check if device is connected to wifi or any mobile data, it won't check if there is internet connection is present or not. So is there any way to add internet connection constraint ?
    :stackoverflow: 3
    f
    • 2
    • 2
  • e

    electrolobzik

    08/06/2020, 2:27 PM
    Hi everyone! I realised that I can’t use
    @Parcelize
    on a nested data class. Why this restriction is present?
    🤔 2
    😮 1
    s
    • 2
    • 6
  • e

    electrolobzik

    08/06/2020, 4:57 PM
    package com.test_parcelize
    import com.test_parcelize.TestNestedParcelize.*
    interface TestI<T : Any>
    class TestNestedParcelize : TestI<State> {
        @Parcelize
        data class State(
                val isLoading: Boolean = false
        )
    }
    In this example `@Parcelize`doesn’t work. I can’t import it, the code analyser breaks. if I replace 
    TestNestedParcelize.*
     to 
    TestNestedParcelize.State
      everything works. Looks like a bug in the kotlin plugin.
    😬 3
    a
    • 2
    • 2
  • m

    Mehdi Haghgoo

    08/07/2020, 8:21 AM
    Hi. With regard to gradle files, what does ext.something mean in buildscript{}? Why not define just def something inside the buildscript{}?
    s
    • 2
    • 1
  • s

    Slackbot

    08/07/2020, 9:49 AM
    This message was deleted.
    :google: 3
    t
    • 2
    • 1
  • a

    Arpan Sarkar

    08/08/2020, 7:01 PM
    What is the difference between
    MergeAdapter
    and the
    ConcatAdapter
    (which is a new class available in 
    recyclerview:1.2.0-alpha02
    ) ?
    a
    • 2
    • 2
  • j

    Joshua

    08/09/2020, 11:47 AM
    Any ideas why this link does not work? It is supposed to open up a web-browser?'
    <TextView
                android:id="@+id/textView6"
                android:layout_width="273dp"
                android:layout_height="45dp"
                android:layout_marginStart="32dp"
                android:layout_marginTop="24dp"
                android:layout_marginEnd="32dp"
                android:autoLink="web"
                android:fontFamily="@font/avenir_next_regular"
                android:text="@string/terms_and_conditions"
                android:textAlignment="center"
                android:textSize="14sp"
                android:textStyle="bold"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/linearLayout3" />
    <string name="terms_and_conditions">By tapping Sign in, you agree to our <a href="<http://www.google.com>" target="_top">Terms</a>. Learn how we process your data in our Privacy Policy and Cookies Policy.</string>
    b
    r
    v
    • 4
    • 14
  • z

    ZariApps

    08/10/2020, 6:23 PM
    hi guys! im brand new, i am learning development/kotlin. quick question. i have a button that should lead to a new page. does that mean i should create a new layout or a brand new activity?
    k
    • 2
    • 6
  • s

    StavFX

    08/10/2020, 6:46 PM
    Given the cost of using enums (vs IntDef), but not wanting to give up on the convenience they add - I was thinking it should be possible to have the compiler (or a build plugin) do the conversion for us (at least for “simple” enums with no methods/inheritance etc), so that we can get the best of both worlds. Does something like this already exist?
    j
    • 2
    • 7
  • p

    pollux-

    08/10/2020, 7:35 PM
    I have a multi module project configured to work with Dagger. I came across a use case, where I need the same component need to be shared with all the activities in the same module. How can I create a shared component without putting it inside the application class
    s
    • 2
    • 1
  • c

    Caio Costa

    08/11/2020, 12:58 AM
    Hey folks, how are you doing? I'd like to know if it's ok to execute a SharedPreferences task inside a Coroutine. I'm just dealing with primitive types so it's just out of curiosity
    g
    a
    • 3
    • 3
  • y

    Yashovardhan

    08/11/2020, 4:08 AM
    This is the approach I usually follow when using firestore. Is there any better approach to implement MVVM architecture when our primary database is Firestore? My main decision was using a single repository object for any firestore related tasks. The viewmodel can then use it just like it uses any other data repository. “Android MVVM pattern with Firebase Firestore” by Yashovardhan Dhanania https://medium.com/@yashovardhan99/android-mvvm-firestore-37c3a8d65404
    s
    • 2
    • 2
  • h

    Halil Ozercan

    08/11/2020, 8:58 AM
    Hi everyone! I'm trying to use the build analyzer in Android Studio 4.0.1 I followed the instructions on this page https://developer.android.com/studio/build/build-analyzer but Build Analyzer tab doesn't show up. Has anyone experienced a similar problem?
    g
    j
    • 3
    • 3
  • r

    Răzvan Roșu

    08/11/2020, 9:43 AM
    HI, does anyone know how to show properly a list inside an item that is part of a RecyclerView?
    :stackoverflow: 6
    r
    • 2
    • 2
  • m

    Maurice Jouvet

    08/11/2020, 3:02 PM
    Thx in advance...
    a
    c
    • 3
    • 5
Powered by Linen
Title
m

Maurice Jouvet

08/11/2020, 3:02 PM
Thx in advance...
a

Alejandro Rios

08/11/2020, 3:13 PM
Search for MVVM with live data on Android
👆 2
c

Casey Brooks

08/11/2020, 3:32 PM
Yup, this is exactly the use-case LiveData was created for
m

Maurice Jouvet

08/12/2020, 12:47 PM
Hum I was excepting this answer. It's not working correctly in my case. I mean, this solution is not a solution on my application context. I'll try to find another way.
Hum I mean, not exactly the solution I was looking for, but after looking to our architecture (which is already mvvm) I can create the algo that will do the works.
Thx
View count: 1