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

    Nathan Kleinschmidt

    09/22/2022, 2:55 PM
    Is there a setup guide for using Intellij with Capacitor/Typescript projects? The project loads and Intellij recognizes that there is an android component, but there are settings I’m not sure about. The docs discuss setting up Typescript projects, but don’t seem to address Capacitor/Typescript specific apps.
    • 1
    • 1
  • a

    Archie

    09/23/2022, 7:44 AM
    Just wondering if anyone knows how to test this scenario?
    fun someFunctionInsideActivity() {
        val intent = try {
            packageManager.getLaunchIntentForPackage("some.app.id")
        } catch (e: Exception) {
            Intent(
                Intent.ACTION_VIEW,
                Uri.parse(webSiteUrl)
            )
        }
        startActivity(intent)
    }
    I want to write
    Espresso
    test for both scenario. I was wondering if its possible to Mock the return of
    packageManager.getLaunchIntentForPackage(...)
    so that I could test both scenario in test. Any ideas? Any other way of testing this would be appreciated. Thanks in advance.
    j
    e
    • 3
    • 5
  • s

    Slackbot

    09/23/2022, 8:08 AM
    This message was deleted.
    g
    u
    • 3
    • 2
  • m

    Michael Pohl

    09/23/2022, 12:39 PM
    I'm wondering if this lambda use creates a potential memory leak:
    class SomeFragment: Fragment() {
        
        val myVal: SomeClass by lazy { 
            SomeClass { requireContext().packageName }
        }
    
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            myVal.runLambda()
            
        }
    }
    
    class SomeClass(
        private val willBeRunSomeTimeInTheFuture: () -> String) {
        
        fun runLambda() {
            Thread.sleep(1000)
            println(willBeRunSomeTimeInTheFuture())
        }
    }
    Trying to wrap my head around if I have to worry when using
    requireContext
    in a lambda that might get executed at a point the fragment is potentially already gone again, and what to do about it. If this is problematic (happy to hear why exactly), would a
    WeakReference
    be enough to mitigate this, like below?
    WeakReference(requireContext()).get()?.packageName ?: ""
    Or do I completely misunderstand something here? Let me know if this example or my question is not sufficient to understand the problem.
    e
    j
    r
    • 4
    • 26
  • a

    Ahmed Sellami

    09/23/2022, 1:40 PM
    Help guys! I want to pass a network call to this function but I couldn't:
    suspend fun <T> wrapNetworkCall(call: () -> T) : NetworkResult<T> {
        return try {
            NetworkResult.Success(call())
        } catch (e: HttpException) {
            if (e.code() == 400)
                NetworkResult.BadRequestError(e)
            else NetworkResult.Error(e)
        }
    }
    coroutineScope.launch {
        val result = wrapNetworkCall {
            Api.retrofitService.getCurrent() // Suspension functions can be called only within coroutine body
        }
    }
    c
    j
    r
    • 4
    • 5
  • l

    Lilly

    09/23/2022, 5:19 PM
    [SOLVED] I have a problem with generics:
    fun <T : ResponsePacket> subscribe(..) : Flow<T> {
        val packet = ResponsePacket()
        emit(packet as T)
        println("what is T: ${packet.javaClass}") // prints ResponsePacket
    }
    
    caller side:
    dao.subscribe<ParameterResponsePacket>()
    The IDE marks the packet as smart casted (green background) but it isn't actually. Any ideas whats is wrong?
    m
    • 2
    • 2
  • a

    Animesh Vashistha

    09/24/2022, 11:10 AM
    Hi Guys
  • a

    Animesh Vashistha

    09/24/2022, 11:11 AM
    Anyone if can help with Android studio errors
  • a

    Animesh Vashistha

    09/24/2022, 11:11 AM
    Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugCompileClasspath'.
  • a

    aridder

    09/24/2022, 12:13 PM
    Hello. I have an issue from migration from groovy to kts for my build.gradle. I dont understand how to use a plugin in my `build.gradle.kts`file.
    build.gradle.kts
    which works:
    • 1
    • 3
  • a

    Amit

    09/24/2022, 4:27 PM
    I'm also interested in knowing the solution for this. You may get a better response for this if you ask in the #compose channel. Do you mind posting this there as well?
    b
    • 2
    • 1
  • j

    Jakub Neukirch

    09/26/2022, 10:22 AM
    Hey, I have noticed many of android components does not have proper customization possibilities so i started rewriting them from scratch. Here is my first component library for NumberPicker: https://github.com/Stonks-tech/GoodPicker And some example of DrawablePicker. Please take a look and let me know if recreating such components (CalendarView coming next) will be useful for you
  • j

    jannis

    09/26/2022, 12:20 PM
    I have a long string. Is there a neat way to get the whole word for a given index in that string? It should respect all common delimiters (whitespaces, comma, question mark,...).
    • 1
    • 1
  • j

    jared

    09/26/2022, 3:13 PM
    Is anyone here from Southern California (Orange County, LA, or San Diego)?
  • s

    Slackbot

    09/27/2022, 12:30 PM
    This message was deleted.
    g
    ю
    • 3
    • 2
  • n

    nuhkoca

    09/27/2022, 12:44 PM
    Cross posting here just in case https://kotlinlang.slack.com/archives/C09222272/p1664279857380159
  • a

    Ahmed Sellami

    09/27/2022, 1:07 PM
    Do you have any experience of using a remote logging system? I am confused about what to choose. I can upload logs to firebase firestore/relatime db, use firebase analytics, or use another provider. What do you think?
    a
    z
    +2
    • 5
    • 11
  • s

    Shreyas Patil

    09/28/2022, 7:44 AM
    Simple Android Question: When we want to check network connectivity in Android, connectivity manager has API of checking capability. Should we… • Get all available networks and then check each network’s capability and if any network has internet capability and if any network has capability then return true • Get active network, check if it has network capability or not What should be the approach and what will be the behaviour difference with both the approaches?
    c
    • 2
    • 1
  • c

    Ciaran Sloan

    09/28/2022, 10:34 AM
    you can use the
    Scaffold
    API for that. The
    content
    lambda receives a
    PaddingValues
    which you can use to retrieve the padding of both top and bottom bars which are provided to the
    Scaffold
    p
    c
    z
    • 4
    • 6
  • s

    Sky

    09/28/2022, 11:56 AM
    Hi guys how can i create a user unique id that will be refreshed once the app is reinstalled( in Kotlin)?
    c
    • 2
    • 1
  • m

    Muhammad Junaid

    09/28/2022, 7:33 PM
    How to integrate slack in Android app? @ any idea? Any site?
  • m

    Muhammad Junaid

    09/28/2022, 7:53 PM
    Any 3rd party 1 to many chat integration (free or paid ) like intercom ?
    m
    g
    • 3
    • 7
  • m

    Milo

    09/28/2022, 9:11 PM
    how to convert list<string, list<string>> to string
    l
    m
    c
    • 4
    • 10
  • a

    Ashish Gautam

    09/29/2022, 6:39 AM
    Hey guys ! I have a Dialogue in a class for global use, I have some event on onClick now I want a check condition that for context like I don't want to trigger that event when a particular context(fragment is there). Basiclly if (context != context(from some fragment))
    j
    • 2
    • 1
  • d

    dave08

    09/29/2022, 11:33 AM
    Is there any good sample of an android compose app that uses good architecture and is completely unit/instrumented tested? All the sample I've seen have just a part of the tests and fake data only....
    j
    c
    +2
    • 5
    • 32
  • s

    Slackbot

    09/29/2022, 1:18 PM
    This message was deleted.
    p
    z
    d
    • 4
    • 3
  • m

    Michael Job

    09/29/2022, 3:20 PM
    Having a Compose for desktop app where a UI-input triggers the load of images from online resources. The loading is done in a coroutine. As long as the UI is triggering new loads, the not yet resolved loading shall be canceled, so that only the last call will be executed. Not sure if I got the coroutine cancellation stuff right, it works as expected, but is there a better way? Thanks for thoughts.
    private val modelScope = CoroutineScope(SupervisorJob() + <http://Dispatchers.IO|Dispatchers.IO>)
    fun loadImageBitmap(id: Int) {
    if (currentId == id) {
    return
    }
    currentId = id
    modelScope.coroutineContext.cancelChildren().also { print(".") }
    //cancel all requests before the current one - prints a dot each just for demonstrating
    modelScope.launch { //Coroutine #1
    delay(500) //simulate longer http request
    println("\njob ${this.coroutineContext.job.hashCode()} gets Image $id")
    currentImage = withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
    URL("$baseUrl$id-1.jpg").openStream()
    }
    .buffered()
    .use(::loadImageBitmap) // loads image
    }
    }
    c
    e
    • 3
    • 5
  • b

    Brandon Howard

    09/29/2022, 5:41 PM
    is the the correct way to determine whether or not my library code is being executed in a debug build?
    val isDebuggable = 0 != applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE
    I tried using
    BuildConfig.DEBUG
    but thats always false
    g
    • 2
    • 11
  • m

    Muhammad Junaid

    09/29/2022, 9:02 PM
    Ilhasoft/data-binding-validator this is 6 year old library Any one know data binding validation library in kotlin? Any other in XML? Your suggestion help me.thanks
    a
    • 2
    • 1
  • p

    Pabitra Ranjan Sahu

    09/30/2022, 9:32 AM
    👋 Hello, team!
Powered by Linen
Title
p

Pabitra Ranjan Sahu

09/30/2022, 9:32 AM
👋 Hello, team!
View count: 10