https://kotlinlang.org logo
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

    Slackbot

    04/16/2021, 8:47 PM
    This message was deleted.
    r
    n
    • 3
    • 19
  • d

    David Martin

    04/17/2021, 2:42 AM
    Good morning guys, I wanna ask you about an efficient way of app’s structure, when I create an app I often use only one activity, then in that activity I include a container fragment and put all other fragments into that container fragment. So is that an efficient way of app’s organization?
    :not-kotlin: 2
    a
    • 2
    • 2
  • m

    max.cruz

    04/17/2021, 6:11 PM
    Just out of curiosity. I have been watching a practice that is becoming popular about using backing properties to shortcut Kotlin nullability check. (For example)
    private var _binding: ViewBinding? = null
    private val binding get() = _binding!!
    And I was wondering why this is better than just a
    lateinit property
    (which, in my humble opinion, is more concise)
    private lateinit var binding: ViewBinding
    Or even if
    _binding
    is going to be mutated to null, it would be better to use the language constructors to check the possibility. Am I missing something?
    a
    o
    +3
    • 6
    • 28
  • a

    A. Sachdeva

    04/18/2021, 3:57 PM
    after upgrading to android studio 4.1 , i am getting this warning for using switch cases in one particular java code:
    Resource IDs will be non-final in Android Gradle Plugin version 5.0, avoid using them in switch case statements
    . i found this article related to this issue : http://tools.android.com/tips/non-constant-fields . i usually use kotlin, but maintain some java projects. as a kotlin user, is it still okay to use
    when-else
    blocks with resource ids? or would that be impacted too ?
    :not-kotlin: 2
    😑 1
    👴 1
    c
    • 2
    • 3
  • c

    Colton Idle

    04/18/2021, 9:08 PM
    Being a kotlin slack, it makes sense that we want all questions to be kotlin related, but I think so many people have found help in this community that it's become "trustworthy" (way more so than that androidunited slack) and because of that it makes sense why people post non-kotlin android questions here. I wish there was an "official" android slack. android-dev irc was fun when there were framework people hanging out. Maybe to "fight" this for now we rename the channel android-kotlin or something?
    ➕ 5
    :not-kotlin: 3
    💯 1
    o
    d
    j
    • 4
    • 3
  • d

    dewildte

    04/18/2021, 10:17 PM
    Language makes software, software is language. Kotlin is now the language of Android. Android is now becoming Kotlin, they are related by definition. There is no need to have, or start, another software war. Why can we not just ask the questions we need answered in the place that is most likely to answer them? GRASP Has the Information Expert principle:
    Assign responsibility to the class that has the information needed to fulfill it.
    This slack community has all the information experts. So it is natural for people to assign theirs questions to here. Fighting this behaviour is probably futile and also alienating to its members.
    🎉 1
    :not-kotlin: 8
    👍 1
    💯 1
    r
    k
    +3
    • 6
    • 39
  • h

    homeless

    04/19/2021, 6:43 AM
    Hello guys, When I use Gson with Kotlin, I experience inconvenience because of unstable nullable parsing, polymorphic deserialize and many things.. So I want use another Json parser, can anyone recommend Json parser library? The specific environment is Retrofit + Gson for http request and I will migration Gson to new json parser. I think moshi is optimal choice, because I know kotlinx.serialization is unstable and still experimental for build retrofit converter. I think I'd be grateful if anyone gave me an opinion 🙇
    o
    • 2
    • 1
  • c

    Chetan Tuteja

    04/19/2021, 7:09 AM
    I know this is not Kotlin question, but does anybody have good experience with Constraint Layout. I can't figure out what constraints to set for a specific scenario
    :not-kotlin: 5
    :google: 4
    j
    a
    g
    • 4
    • 8
  • h

    Hovhannes

    04/19/2021, 7:26 AM
    Hello, when I pass to a fragment from another fragment, the previous fragment is visible. What is the reason?  The height of all fragments are match_parent.
    val compFragment = CompFragment()
     compFragment.arguments = bundle
     requireFragmentManager().beginTransaction().replace(R.id.comp_item, compFragment)
         .commit()
    :not-kotlin: 8
    u
    • 2
    • 2
  • a

    Andrean Firmansyah

    04/19/2021, 9:07 AM
    🙋 Roll call! Who else is here?
    🙌 2
    🎲 1
    :not-kotlin: 13
    😠 3
    ✋🏼 1
    ☝️🏼 1
    😮 1
    ✋ 3
    l
    d
    +2
    • 5
    • 4
  • h

    Hovhannes

    04/19/2021, 11:06 AM
    Hello everybody, when I pass to a fragment from another fragment, the previous fragment is visible. What is the reason?  The height of all fragments are match_parent and background colors are different.
    val compFragment = CompFragment()
     compFragment.arguments = bundle
     requireFragmentManager().beginTransaction().replace(R.id.comp_item, compFragment)
         .commit()
    :stackoverflow: 4
    :not-kotlin: 5
    d
    • 2
    • 1
  • o

    okarm

    04/19/2021, 11:26 AM
    ☝️ Added the r/androiddev Discord server to the list of relevant communities. It has 11k members and is the ideal place for general Android questions. Edit: Sorry about the spam - Slack did not indicate that it would ellipsize the description (didn't display the limit warning) 🙂
    👍 1
    a
    • 2
    • 1
  • f

    Farid Mrz

    04/19/2021, 2:37 PM
    hello anyone here using registerForActivityResult() in a fragement while overriding onActivityResult in the host activity. My callback never gets called
    :not-kotlin: 8
    e
    s
    • 3
    • 10
  • n

    Nikhil

    04/20/2021, 5:38 AM
    Which one is better to use in android projects?
    Parcelable
    or
    Serializable
    ?
    b
    a
    +3
    • 6
    • 7
  • h

    hsyogesh

    04/20/2021, 6:21 AM
    Hi I am using net.sqlcipher to encrypt my app database, we are getting device specific crashes logged in firebase in field, logs are pasted below, suggestions will be appreciated Fatal Exception: java.lang.IllegalStateException database not open  (SQLiteDatabase.java:109)  (AndroidSqliteDriver.java:6)  (Transacter.java:6)  (TransacterImpl.java:25)  (TransacterImpl.java:5)  (TransactionExternsionsKt.java:16) Fatal Exception: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/com.philips.phsleep-reJnoXvYSDyN5sVbGFw0mQ==/base.apk”],nativeLibraryDirectories=[/data/app/com.philips.phsleep-reJnoXvYSDyN5sVbGFw0mQ==/lib/x86, /system/lib, /vendor/lib]]] couldn’t find “libsqlcipher.so” at java.lang.Runtime.loadLibrary0(Runtime.java:1011) at java.lang.System.loadLibrary(System.java:1657) at net.sqlcipher.database.SQLiteDatabase$1.loadLibraries(SQLiteDatabase.java:6) at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:9) at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:8) at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:7) at net.sqlcipher.database.SupportHelper.<init>(SupportHelper.java:5) at net.sqlcipher.database.SupportFactory.create(SupportFactory.java:8) at com.squareup.sqldelight.android.AndroidSqliteDriver.<init>(AndroidSqliteDriver.java:2) at com.squareup.sqldelight.android.AndroidSqliteDriver.<init>(AndroidSqliteDriver.java:55) at com.hp.sleep.shared.datasource.DataSourceProvider.open(DataSourceProvider.java:76) at com.philips.phsleep.SleepApplication.openDB(SleepApplication.java:9)
    :not-kotlin: 7
    😂 2
    m
    d
    • 3
    • 3
  • s

    Sivan

    04/20/2021, 2:42 PM
    So I tried setting an error while validating a text field and the error shows up at the end of the view below the icon, like this. How do I make sure that the error is the the form of a text only, and is right below the text input field?
    😂 3
    :not-kotlin: 12
    j
    a
    • 3
    • 5
  • v

    Vaibhav Jaiswal

    04/20/2021, 7:41 PM
    Hi! I had a question. Why setMaxDate is not available in Kotlin's DatePickerDialog? I am attaching the picture of code. You see, the IDE doesn't seem to suggest me setMaxDate and insetead suggests about maxDate which is another function
    n
    • 2
    • 2
  • a

    alex.tavella

    04/21/2021, 7:11 PM
    [Flow + LiveData]
    Hi, we have been adopting
    Flow
    on our app and there are still some behaviors that we want to achieve that are a bit unclear. So, our presentation architecture basically consists on archictecture component’s
    ViewModel
    producing state in a
    ViewState
    class that has its properties exposed as
    LiveData
    , which are observed by the
    View
    layer. We have a case similar to the following:
    internal class HomeViewModel constructor(
        observeSessionAddress: GetSessionAddressFlowUseCase,
        getHome: GetHomeUseCase,
    ) : ViewModel {
        private val addressStream = observeSessionAddress()
            .distinctUntilChanged()
            .shareIn(viewModelScope, SharingStarted.Lazily, replay = 1)
    
        private val homeStream = addressStream
            .map { getHome(it.lat, it.lon) }
            .shareIn(viewModelScope, SharingStarted.Lazily, replay = 1)
    
        val viewState = HomeViewState(
            addressStream.asLiveData(),
            homeStream.asLiveData()
        )
    }
    
    internal class HomeFragment : Fragment() {
    ...
        override fun onViewCreated(
            view: View,
            savedInstanceState: Bundle?,
        ) {
            super.onViewCreated(view, savedInstanceState)
            ...
            with (viewModel.viewState) {
                address.observe(viewLifecycleOwner, ::updateAddress)
                home.observe(viewLifecycleOwner, ::updateHome)
            }
        }
    }
    The class
    GetSessionAddressFlowUseCase
    returns a
    Flow
    . The code works fine, when Fragment is firstly created, it starts observing the address and fetches home content appropriately and also when navigating forward and getting back, we get the previous value without actually triggering
    getHome
    again. The only problem is: by using
    shareIn
    I just made
    homeStream
    and
    addressStream
    hot flows, and after leaving
    HomeFragment
    by navigating forward (we replace this fragment and keep in the backstack, so only
    onDestroyView
    is called), the hot flow will still be live since
    HomeViewModel
    is still alive and hence if we change address on another screen, the
    getHome
    use case will still trigger. That may seem harmless at first, but if other devs start following this approach, we might trigger a bunch of expensive operations even if that info is not important to the user at that moment. One alternative is to keep these streams as cold, but after navigating back to the
    Fragment
    would trigger
    getHome
    again, which is an expensive operation, so that is out of the question. Any ideas/suggestions?
    l
    a
    • 3
    • 15
  • s

    Shailan Patel

    04/22/2021, 12:22 AM
    does anybody know how https://pastebin.com/5JYdjBeE differs from https://pastebin.com/jr3DxT5a ?
    v
    • 2
    • 1
  • s

    Slackbot

    04/23/2021, 1:50 PM
    This message was deleted.
    m
    • 2
    • 3
  • o

    Orhan Tozan

    04/23/2021, 2:33 PM
    In Fragment collecting a UI state Flow, which one of the following scopes you use to collect UI state? 1️⃣`lifecycleScope` 2️⃣`viewLifecycleOwner.lifecycleScope`
    2️⃣ 13
    1️⃣ 1
    j
    • 2
    • 3
  • o

    Orhan Tozan

    04/23/2021, 2:40 PM
    In a Fragment collecting a UI state Flow, which one of the scope methods do you use? 1️⃣`launch {}` 2️⃣`launchWhenCreated {}` 3️⃣`launchWhenStarted {}` 4️⃣`launchWhenResumed {}`
    4️⃣ 2
    3️⃣ 12
    2️⃣ 2
    1️⃣ 8
    j
    • 2
    • 2
  • e

    escodro

    04/23/2021, 5:18 PM
    Hello, everyone ! 👋 Quick question: when I create a Kotlin only module in an Android Project (
    apply plugin: 'kotlin'
    ), do I have to setup anything for ProGuard/R8? In other all modules, there is
    minifyEnabled
    set to
    true
    , but this setup is inside
    android
    tag. Thanks a lot in advance! ❤️
    :not-kotlin: 2
    e
    k
    • 3
    • 5
  • a

    am414

    04/25/2021, 1:20 AM
    hello everyone i saw this code and i didnt understand how this guy make this it passes the actions and show the view, is it a class with higher order functions or what ? is there a tutorial to learn this kind of code thanks
    alert("We can't show your position because you generally disabled the location service for your device.") {
            yesButton {
            }
            neutralPressed("Settings") {
                startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS))
            }
        }.show()
    e
    l
    d
    • 4
    • 5
  • s

    Sivan

    04/25/2021, 1:17 PM
    Quick question : Do my view IDs (in integer) change after every clean install of the app? Example : I've given an id to the card view via XML (let's say it's called safeCard) Now this view has an integer ID to it. I'm saving this on my database and retrieving it for a user. So when I reinstall my app, does safeCard's id change?
    :not-kotlin: 2
    z
    e
    d
    • 4
    • 4
  • s

    Slackbot

    04/25/2021, 3:28 PM
    This message was deleted.
    a
    o
    • 3
    • 2
  • c

    coroutinedispatcher

    04/25/2021, 8:02 PM
    Any nice way of handling this use case with the Kotlin
    with
    keyword?
    with(myFragmentBinding){
       viewId.text = stateDataClass.name
       viewId2.text = stateDataClass.lastName
       viewId3.text = stateDataClass.phoneNumber
    }
    And I was thinking if there is any nice way of also not repeating the right part. Something like
    with(Pair(binding, modelClass))
    doesn’t look pretty nice to me as it might look a little bit ugly and not intuitive (
    first.viewId.text = second.name
    ) which I don’t like. A nested with is also ugly IMO. Any opinions, thoughts?
    m
    • 2
    • 1
  • s

    Slackbot

    04/26/2021, 1:57 AM
    This message was deleted.
    h
    a
    • 3
    • 3
  • a

    Android75

    04/26/2021, 3:05 AM
    I'm new in Kotlin Flow. I'd like use with Retrofit but i don't understand if and when can i use Flow in Retrofit interface. I 'm using slack eithernet to get network response :
    @GET("v2//news")
    suspend fun news() : ApiResult<List<News>, ErrorResponse>
    In this way i can't use
    Flow<ApiResult<List<News>, ErrorResponse>>
    so can i use in repo?
    fun getNews(): Flow<List<News>> {
    return flow {
    }
    }
    i
    z
    p
    • 4
    • 6
  • m

    Mohan Babu Malairaj

    04/26/2021, 6:45 AM
    hi team, I have an app that works with in a specific set up, we install few other apps that this app will communicate to, and also in a stand alone mode where this specific can alone be installed and used. If this app is in stand alone mode then the login is handled by this app and if this is part of the specific set up, as mentioned above, then Login is handled by Custom Launcher app so this app just gets the token and authenticates the user rather showing a Login screen and asking user to enter data. How do we usually differentiate the stand alone mode is the question here ? Please share your views and experiences.
    :not-kotlin: 7
    k
    k
    +2
    • 5
    • 10
Powered by Linen
Title
m

Mohan Babu Malairaj

04/26/2021, 6:45 AM
hi team, I have an app that works with in a specific set up, we install few other apps that this app will communicate to, and also in a stand alone mode where this specific can alone be installed and used. If this app is in stand alone mode then the login is handled by this app and if this is part of the specific set up, as mentioned above, then Login is handled by Custom Launcher app so this app just gets the token and authenticates the user rather showing a Login screen and asking user to enter data. How do we usually differentiate the stand alone mode is the question here ? Please share your views and experiences.
:not-kotlin: 7
@kenkyee @Kirill Grouchnikov I dont undersand your response. This is an android question and posted in android channel.
k

Kirill Grouchnikov

04/26/2021, 1:40 PM
This is a Kotlin slack. This channel is not for general Android questions. See channel description.
k

kenkyee

04/26/2021, 2:13 PM
Scroll back and read the channel info
I'm trying to make pizza that tastes like Android... Think pesto would work? 😂
m

Mohan Babu Malairaj

04/26/2021, 2:21 PM
Cool, i just posted this question by seeing the channel name.
But do you have any comments or feedback about the question ?
@Zach Klippenstein (he/him) [MOD] Do you have any suggestions for my above question ?
z

Zach Klippenstein (he/him) [MOD]

04/26/2021, 2:39 PM
Nope, sorry
m

Mohan Babu Malairaj

04/26/2021, 2:41 PM
Could you let me know if the question is clear ? Or do i have to rephrase it so that it will be clear ?
:not-kotlin: 3
c

Colton Idle

04/26/2021, 3:00 PM
@Mohan Babu Malairaj unfortunately you're likely not to get any answers since your question is not kotlin related. Probably better off asking in Stack overflow.
🆗 1
👍 1
☝️ 1
View count: 4