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

    ruiter

    08/12/2021, 11:39 AM
    Hi guys, What approach do you use when you have a feature with several steps ? where these steps are fragments. Do you use a viewmodel for each fragment or a sharedViewModel for all fragments?
    :not-kotlin: 5
    s
    c
    +2
    • 5
    • 5
  • o

    oday

    08/12/2021, 2:43 PM
    I am working with a project that has a
    buildSrc
    directory which I’ve cleaned up and no longer need right now, but i still see it being built on every ..build, I cannot seem to find the directive that is letting gradle know that it needs to do this, i would like to stop doing this, how can I?
    v
    e
    • 3
    • 3
  • s

    Samiullah Kalhoro

    08/12/2021, 9:06 PM
    Hello guys, is it ok to start android development with new jetpack compose?
    :yes: 16
    z
    • 2
    • 1
  • a

    Amir Rudd

    08/13/2021, 5:10 AM
    message has been deleted
    r
    • 2
    • 3
  • p

    Pardeep Sharma

    08/13/2021, 12:21 PM
    I am working on a sample of a multimodule project: Aurora. But, while using the Navigator module I am facing:
    'navigator:kaptGenerateStubsDebugKotlin FAILED'
    error. I am really blocked and could not move forward due to the Gradle error. The full logs:
    f
    • 2
    • 3
  • c

    Chris Fillmore

    08/13/2021, 3:27 PM
    message has been deleted
    e
    • 2
    • 2
  • o

    Omotayo

    08/14/2021, 8:37 PM
    Yes but I’m using this in a Kotlin code, thanks to the Kotlin/Java interops
    :thread-please: 4
    e
    • 2
    • 2
  • o

    Omotayo

    08/14/2021, 8:38 PM
    I just want to know how to get to the external dir in Kotlin
    :thread-please: 2
    k
    • 2
    • 6
  • o

    Omotayo

    08/14/2021, 8:39 PM
    Any help would be greatly appreciated
    :thread-please: 2
    c
    a
    • 3
    • 3
  • c

    Cicero

    08/15/2021, 11:07 AM
    Good morning. In a journey to extinguish XML I dived into an adventure of localizing my code using kotlin instead. Everything started with a curious Swift code that did something like "string".localize. This really excited me. But I will appreciate some feedback from Android seniors about taking downs this road and problems that will kick me in the butt too late to avoid doing a major refactor. Feedback will be much appreciated. For a World with more Kotlin.
    👀 1
    a
    a
    • 3
    • 19
  • c

    Cicero

    08/15/2021, 11:44 AM
    An observation about the context of context warning tags I've seen around the Kotlin community. This allows very unhelpful people to come and tag context as if didn't belong there without any helpful information/feedback of the why this is happening. This is a people repellent, if you want to be helpful and improve general behavior, be informative about the tag you added to someones post or just don't. I know this brings you this little satisfaction of doing something but you are not helping anything but your ego. People don't share a the same understanding you believe it's "common".
    👍 1
    k
    • 2
    • 4
  • u

    ursus

    08/15/2021, 1:37 PM
    Is it possible to have transparent navigation bar for swipe navigation; and solid for buttons?
    :not-kotlin: 3
    🔥 1
    p
    • 2
    • 2
  • r

    rajesh

    08/16/2021, 12:19 PM
    I've Room Entity called
    Post
    , and it has property called
    isLiked
    . I want to retrieve its value in repository class to determine whether to like or unlike a post. I'm using below code but app automatically crash with
    I/Process: Sending signal. PID: 12911 SIG: 9
    when using below code block. what am i doing wrong?
    @Query("SELECT * FROM posts WHERE postId = :postId")
    fun isPostLiked(postId: Long): Post
    suspend fun toggleLike(postId: Long) {
        Log.d(TAG, "inside toggle like")
        if (db.postDao.isPostLiked(postId = postId).isLiked == true) {
            Log.d(TAG, "unlike post")
        } else {
             Log.d(TAG, "like post")
        }
    }
    j
    i
    • 3
    • 7
  • y

    Yuval Dryer

    08/16/2021, 3:35 PM
    Hi All, I'm trying to run a Ktor server on android but cannot get the static webpage to display on the browser. I've added an assets folder and place the website as a subfolder in it, The request is recognized but the path I give in the response always seems to be wrong. Any ideas what I'm doing wrong?
    j
    c
    • 3
    • 3
  • s

    suhas

    08/17/2021, 9:35 AM
    How do I get Hours and Minutes left from a UTC formatted data and time string? I am looking at
    Duration
    class. Is that the right approach?
    2021-08-17T12:00:00.235Z
    - Give a time like this, I need to find the hours and mins left from my local time.
    c
    t
    • 3
    • 4
  • c

    curtjrees

    08/17/2021, 1:29 PM
    Has anyone here figured out the specs for the assets on the new Android 12 Splash Screen APIs? Currently trying to figure out sizes for the “AnimatedIcon” and the “BrandingImage” but can’t find any details on them
    :not-kotlin: 1
    c
    • 2
    • 1
  • p

    PhongBM

    08/18/2021, 4:03 AM
    I use app:drawableStartCompat with vector drawable color is white, but when showing, this image display wrong color. Do you know this bug,, please help me
    :not-kotlin: 4
    g
    • 2
    • 1
  • s

    suhas

    08/18/2021, 12:28 PM
    WorkManager?
    t
    • 2
    • 1
  • t

    Travis Griggs

    08/18/2021, 11:49 PM
    Probably more of an AndroidStudio question... but... This expression:
    Base64.decode("eF4Nzr1NBDEQQGEjQXot3FZw8nj8mxIcyUIAghTNeMawWsHB7SJ0HVABvdEANRDi_HvSO9s-0ki3o77vp7s8PrT7WU_m_Pfv5-v7Qj7UbKyiUCGEQiASLETHDBI4i8ekIXOBVCNgspxraYKIvrYQsYSKVIEzOxsokDbffZHCyQljlqjFJ3HNN6kdFK-xiPfJZhbHVYmsBfNGy9KnwGw92F5WdMm21neeD8s6idnsrk_D5fQ07Gkdro6q83Cj6-fhOJtXelFj_gHcOkP7", Base64.NO_PADDING or Base64.NO_WRAP or Base64.URL_SAFE)
    In an InstrumentTest (so runs on the device) works fine. But run it from a simple unit test (which runs on the development box--mac os in this case--i believe), and it fails. returns null every time. Gives me the heeby jeebies about relying on unit tests.
    p
    e
    +2
    • 5
    • 6
  • g

    g4sarma

    08/19/2021, 10:05 AM
    Has anyone had some issue with trying to migrating Koin from V2 to V3 and getting rid of the Jcenter dependency in the dependency. I was able to sync gradle but i am not able to recognise the io.insert-koin in my project when trying to import the same in my class. Has anyone faced a similar problem ?
    :not-kotlin: 3
    h
    k
    e
    • 4
    • 12
  • h

    Hovhannes

    08/20/2021, 1:41 PM
    Hello, I've a difficult question. I get  this error   'java.lang.IllegalArgumentException: SavedStateProvider with the given key is already registered'. What is the reason?
    Fragment
    private var instance: LoginFragment? = null
     private val viewModel by viewModels<AuthViewModel>()
     override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
            super.onViewCreated(view, savedInstanceState)
            binding = FragmentLoginBinding.bind(view)
            instance =this
    }
    
    fun login(): String {
        viewModel.login(clientId, partner.toString(), password)
        val clientId = binding.editTextTextEmailAddress.text.toString().trim()
    
        val encrypted = encrypt(clientId, publicKey)
      
        return encrypted
    }
    RemoteDataSource
    private fun getRetrofitClient(): OkHttpClient {
    
        val str= LoginFragment().getInstance()?.login()
    ....
    :not-kotlin: 2
    :android-dance: 1
    c
    c
    • 3
    • 3
  • a

    Andre Stefanov

    08/22/2021, 12:35 PM
    Is there a way to make use of Ktor Locations on android http client? The idea is to have shared module between android and ktor backend and thus define the routes and models only in one place
    d
    m
    • 3
    • 5
  • s

    suhas

    08/22/2021, 1:15 PM
    Can bubbles be used for purposes other than chat? https://developer.android.com/guide/topics/ui/bubbles#kotlin
    :android: 2
    :not-kotlin: 4
    m
    • 2
    • 1
  • t

    TarunY

    08/22/2021, 5:41 PM
    Hi Guys, can you suggest me how to solve below issue & attached the code
    s
    • 2
    • 3
  • o

    Orhan Tozan

    08/23/2021, 10:33 AM
    What do you guys think? Is Android Navigation 2.4.0-alpha07 ready for production use?
    f
    r
    • 3
    • 2
  • s

    Sololo

    08/23/2021, 11:54 AM
    Hi gays, I got an error
    Camera.CAMERA_ERROR_EVICTED
    on
    camera.setErrorCallback {}
    callback.
    :not-kotlin: 1
    🏳️‍🌈 11
    l
    • 2
    • 2
  • s

    Stylianos Gakis

    08/23/2021, 3:23 PM
    I’m working with Datastore and it’s asynchronous nature and Okhttp authentications. Having some trouble breaching this Java <-> Coroutines gap. More details in thread 🧵
    l
    o
    • 3
    • 8
  • v

    Vyshas

    08/23/2021, 4:45 PM
    Is there a way to add default fragment enter and exit transition at a single place for all fragment navigations in a project that uses jetpack navigation?
    s
    • 2
    • 1
  • l

    lawlorslaw

    08/23/2021, 7:53 PM
    I am getting the following Kotlin warning on my circle ci build
    No cast needed
    i tried adding the suppress annotation but still get the same warning
    @Suppress("UNCHECKED_CAST")
    val viewStub = (parentBottomTabs as ViewStub)
    How do i properly suppress this warning?
    • 1
    • 1
  • j

    Jason Inbody

    08/24/2021, 12:07 AM
    I'm trying to implement a facebook login flow with jetpack compose, unfortunately I'm having issues with getting
    rememberLauncherForActivityResult
    to hit. What I have gotten to work is to write my own activity class to handle the facebook callback and I'm able to get the token from facebook. The problem is I don't know how to pull the token out of an activity as I can't pass any callbacks into the activity... I was looking into maybe using a broad cast receiver to send the token out of the activity result back to the jetpack compose code. I'm newish to android so unsure if the broadcast receiver is the best way to do this? Is there better ways to send a string out of an activity than that?
    • 1
    • 2
Powered by Linen
Title
j

Jason Inbody

08/24/2021, 12:07 AM
I'm trying to implement a facebook login flow with jetpack compose, unfortunately I'm having issues with getting
rememberLauncherForActivityResult
to hit. What I have gotten to work is to write my own activity class to handle the facebook callback and I'm able to get the token from facebook. The problem is I don't know how to pull the token out of an activity as I can't pass any callbacks into the activity... I was looking into maybe using a broad cast receiver to send the token out of the activity result back to the jetpack compose code. I'm newish to android so unsure if the broadcast receiver is the best way to do this? Is there better ways to send a string out of an activity than that?
So it looks like I should use putExtra to set a key/string pair. In my activity
override fun onSuccess(loginResult: LoginResult?) {
    val token = loginResult?.accessToken?.token
    intent.putExtra("token", token)
}
I set the putExtra to token. In my compose code I start a thread waiting for the token to be set
Thread {
    while (intent.getStringExtra("token") == "") {
        val tok = intent.getStringExtra("token")
        Thread.sleep(1000)
    }
    val token = intent.getStringExtra("token")
}.start()
I verify with break points that the token is being sent but when I set the break point back in my thread the token is never set...
Alright that didn't work either. I just used a singleton to share data between the compose and activity which worked
View count: 65