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

    hfhbd

    01/19/2022, 10:13 PM
    Anybody else having issues with IntelliJ Ultimate and the android emulator on a M1 Mac? I use a arm based emulator image, but qemu uses 100% CPU and hangs
    p
    • 2
    • 5
  • s

    Slackbot

    01/20/2022, 2:37 PM
    This message was deleted.
    u
    l
    c
    • 4
    • 4
  • z

    zain

    01/21/2022, 5:58 AM
    Anybody good with regex? https://stackoverflow.com/questions/70796990/regex-to-find-all-occurrences-of-string-serializedname
    :not-kotlin: 3
    j
    v
    • 3
    • 2
  • o

    oday

    01/21/2022, 9:46 AM
    has anyone ever encountered this within Android Studio?
    m
    • 2
    • 3
  • f

    Freedom

    01/21/2022, 10:01 AM
    I am trying to understand what the plus operator means in this Context
    z
    j
    • 3
    • 4
  • a

    Ameen Essa

    01/21/2022, 11:20 AM
    Morning, any one can help my with a good lib for QR and Barcode scanning with Koltin
    r
    m
    • 3
    • 3
  • v

    Vignesh

    01/22/2022, 12:03 PM
    Hi, I am using In-app immediate update After download finished app is not restarting How to solve this issue? I am using Google in app update feature one is flexible and another one is immediate.now i am using the immediate update.In the Google documentation they said after download is finished the app restart again.but in my case it is not happening.i am using Android 11
    :not-kotlin: 4
    u
    v
    • 3
    • 5
  • u

    Umar Ata

    01/22/2022, 12:29 PM
    What is the best way to capture the progress of file upload and download using Retrofit with kotlin I have two different codes 1. I created a request extended class and performing update and getting callback in interface 2. I created extension function with request body and collecting it in flow by calculating the file size and content delivered But in both cases I have to write a lot and I need one plug and play solution, by above i created a function and calling it from many places Any recommendations?
    z
    • 2
    • 6
  • a

    Arun Joseph

    01/23/2022, 7:57 AM
    Is buildSrc is the recommended approach to create custom gradle plugins and scripts for Android projects?
    :yes: 2
    e
    • 2
    • 3
  • z

    zain

    01/24/2022, 6:14 AM
    Does anybody has a good blog around in memory (not db) state management for list items, add, update, delete) If I want to update an item in the list without mutating the objects. Like I don't want to use
    var
    Pure Kotlin
    :not-kotlin: 1
    а
    a
    • 3
    • 2
  • v

    Vivek Modi

    01/24/2022, 4:11 PM
    Hey I want to remove text from string for example
    val string = "Hey 123"
    or
    val string = "Hey How are you 123"
    and output
    string = 123
    :stackoverflow: 3
    j
    v
    +2
    • 5
    • 12
  • e

    edward

    01/24/2022, 4:24 PM
    Still trying to think of an android question that's Kotlin-specific enough for this channel.
    :not-kotlin: 7
    👍 1
    😁 3
    z
    j
    +3
    • 6
    • 5
  • c

    Chethan

    01/24/2022, 6:07 PM
    I have situation here , Live data Observer is set on database object to collect some stack of cards , These stack of cards is shown sequentially to user for every 2 minutes . once this card is shown , I will have to update database to modify its status . but you know how the live data work with room, every time you make update specific row, live data will retrigger (you can read here) , that will call whole flow once again which needs to be avoided To avoid this re-triggering , I made some modification, I will collect cards at the initial, and soon after that I will remove observer My code looks as below
    observer = Observer<Resource<List<DisplayCard>>> {
        when (it.status) {
            Status.SUCCESS -> {
                // setting list to emit card for every 2 minutes once
                ambientDisplayViewModel.setListOfCards(it.data ?: emptyList())
                // removing observer
                ambientDisplayViewModel.ambientCardList.removeObservers(viewLifecycleOwner)
            }
            Status.LOADING -> {
            }
    
            Status.ERROR -> {
                ambientDisplayViewModel.refresh(DataSource(loadFromNetwork = false))
            }
        }
    
    }
    With above code , I have received review comments from my peer as below "Viewmodel callback should come to activity/fragment only when there's an intention to update the view." , Do you agree on this quote ? Do you think that I shouldn't keep callback when I am not making any UI
    :not-kotlin: 3
    u
    • 2
    • 1
  • t

    Tran Thang

    01/25/2022, 5:10 AM
    hi guys: Can anyone explain to me why it outputs like this?
    e
    c
    g
    • 4
    • 6
  • j

    Joe Altidore

    01/25/2022, 6:29 AM
    Hey guys. How do ensure an edit text only accepts alphabets and digits? I.e A-Z,a-z,0-9 only
    :not-kotlin: 2
    r
    t
    • 3
    • 2
  • d

    dave08

    01/25/2022, 2:34 PM
    I don't feel too comfortable to put up a bunch of dependencies in the application's component when the workers might be already finished and the app might be running... so having a scope for it would maybe make sense? Or maybe use it's service's scope?
    • 1
    • 2
  • m

    Michael Langford

    01/25/2022, 4:16 PM
    Hi there. We'd specced this app to use on-device barcode scan when starting the process, but it appears MLKit by google still tries to send analytics despite being given lots of configuration params telling it not to. Does anyone use that library and know how to actually configure it to stop phoning home? (Compliance reasons, not just personal preferences here).
    :not-kotlin: 3
    k
    e
    • 3
    • 6
  • m

    Mohamed Tamer

    01/25/2022, 9:21 PM
    Hi there , what is difference between object and companion object in singleton pattern ? and what's good way ? , Do both methods have no problem when using? !!!
    z
    p
    • 3
    • 4
  • e

    Eimantas Urbonas

    01/26/2022, 10:56 AM
    How often do you use livetemplates? I am a new android dev with ADHD and just discovered live templates. They make my life much easier, for example I have shortcuts for generating recyclerview adapter/viewholder/implementation boilerplate code. In that way I am able to focus on implementation, and do my coding like building blocks, rather than memorizing every detail of implementation. Also I don't need to go to stackoverflow and copypaste basic things multiple times. Even for example during live coding interview having livetemplates seems awesome, copypasting from stackoverflow would be shameful (I think). Using my own custom shortcuts for livetemplates seems the best way for how my brain functions (I suck at memorizing tiny details, but I remember general idea/flow of a pattern and I would prefer memorizing what to use and when to use, instead of all small details of implementation). Is getting to dependent on livetemplates a good practice to get used to? Do other developers frown upon a dev who has dozens of livetemplates and relies on them instead of writing all code from memory by hand?
    :not-kotlin: 2
    a
    z
    • 3
    • 3
  • v

    Vivek Modi

    01/26/2022, 1:59 PM
    Hey I am getting error on my unit test.
    j
    • 2
    • 3
  • a

    Arilson José de Oliveira Júnior

    01/26/2022, 2:04 PM
    Hi Guys! My name is Arilson and I’m a teacher and Android developer. I hope to learn and help here!
    👋 8
    h
    • 2
    • 1
  • c

    Chris Fillmore

    01/26/2022, 6:21 PM
    Is there an idiomatic way to expose state from a Service to the UI? My use case is in a live streaming app with some complex, stateful, and tightly coupled signalling running in a Service. Some of this state needs to be exposed to the user. However, attempting to do so (e.g. through a ViewModel) leads to a lot of boilerplate, mapping Flows and such, and duplicating default/initial state. Any advice?
    :not-kotlin: 1
    u
    j
    • 3
    • 2
  • e

    edward

    01/26/2022, 8:40 PM
    Looking here: https://developer.android.com/guide/fragments/communicate
    class ListFragment : Fragment() {
        // Using the activityViewModels() Kotlin property delegate from the
        // fragment-ktx artifact to retrieve the ViewModel in the activity scope
        private val viewModel: ItemViewModel by activityViewModels()
    wtf is
    activityViewModels
    ?
    :not-kotlin: 2
    a
    z
    • 3
    • 7
  • e

    edward

    01/26/2022, 10:54 PM
    How do I actually add the repository I need for this?
    > Could not find androidx.fragment.fragment-ktx:1.3.2:.
         Required by:
             project :app
    This doesn't make any sense: https://developer.android.com/studio/build/dependencies#google-maven
    i
    • 2
    • 2
  • c

    Colton Idle

    01/27/2022, 12:26 AM
    Posting here because I think this is not really compose related, and so maybe someone has an idea here. tldr, updated to the new androidx releases today and now we cant build due to this error.
    t
    j
    s
    • 4
    • 4
  • t

    tonnyl

    01/27/2022, 6:07 AM
    I've tried the new way to construct the viewmodels in activities according to the [docs](https://developer.android.com/jetpack/androidx/releases/lifecycle#lifecycle-viewmodel-compose-2.5.0-alpha01), it feels good. But I didn't find a way to provide the
    defaultViewModelCreationExtras
    in compose, did I miss something?
    i
    c
    • 3
    • 4
  • a

    Abhinav Bhadauria

    01/27/2022, 6:30 AM
    Hi guys, can someone help me out, my app is in review since last 8 days, and i mailed them and talked with Google support but still no solution I got, is there anything which I am doing wrong or it is from their end
    :not-kotlin: 5
    c
    • 2
    • 1
  • h

    Hafs

    01/27/2022, 10:06 AM
    Hello Guys, anybody know how to write UI test verify image view with jet pack compose?
    l
    • 2
    • 1
  • d

    Danish Ansari

    01/28/2022, 6:50 AM
    I have
    sealed
    class
    AppState
    with 4 states (3 object and 1 one data class having 1 immutable property). It is used in
    ViewModel
    as private
    MutableLiveData
    and exposed to activity as
    LiveData
    I'm using it in compose using
    LiveData.observeAsState()
    Now the issue I'm facing is that when I use the variable
    State<AppState>
    (variable name is appState) using
    when
    block I'm able to access that 1 data classess property but I'm getting compilation error (Smart cast to 'AppState.Success' is impossible, because 'appState' is a property that has open or custom getter) Code snippet inside thread
    z
    • 2
    • 5
  • e

    Eimantas Urbonas

    01/28/2022, 4:26 PM
    I need help with viewpager2 implementation. For some reason it's lagging when I swipe (on emulator and on real device as well). Here is the proof:

    https://www.youtube.com/watch?v=uoj_PWWUApU▾

    and here is my repo where I reproduced the issue https://github.com/eurbon/viewpager2_lagging can anyone help me?
    :not-kotlin: 2
    c
    • 2
    • 2
Powered by Linen
Title
e

Eimantas Urbonas

01/28/2022, 4:26 PM
I need help with viewpager2 implementation. For some reason it's lagging when I swipe (on emulator and on real device as well). Here is the proof:

https://www.youtube.com/watch?v=uoj_PWWUApU▾

and here is my repo where I reproduced the issue https://github.com/eurbon/viewpager2_lagging can anyone help me?
:not-kotlin: 2
c

Chrimaeon

01/28/2022, 5:24 PM
Load the images in the background.
setImageResource
is running on the main thread.
e

Eimantas Urbonas

01/28/2022, 5:51 PM
@Chrimaeon thank you, problem solved! I used glide for loading like this
fun bind(myImage: Int) {
    binding.apply {
        Glide
            .with(imageview1.context)
            .load(myImage)
            .centerCrop()
            .into(imageview1)
    }
}
👍 2
View count: 12