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

    adams2

    06/04/2019, 5:54 PM
    does kotlin-android-extensions still not work with files in
    src/debug/res/layout
    • 1
    • 3
  • j

    Jarek

    06/04/2019, 6:07 PM
    hey guys, what is best practice for a view/edit form toggle?
    :stackoverflow: 6
    k
    • 2
    • 1
  • g

    Gautam Lad

    06/05/2019, 2:34 AM
    Hey guys, With the new viewModelScope, when it gets cancelled, why doesn’t future launch call do anything?
    viewModelScope.launch(<http://Dispatchers.IO|Dispatchers.IO>) {
                contentLiveData.postValue(getDiscoverContentUseCase.execute())
            }
    If I put a breakpoint on launch line I see it’s cancelled.
    viewModelScope = {CloseableCoroutineScope@5985} 
     coroutineContext = {CombinedContext@5986} "[SupervisorJobImpl{Cancelled}@7ed8dea, Main]"
    i
    l
    m
    • 4
    • 39
  • i

    itnoles

    06/06/2019, 5:14 AM
    About Fragment implements CoroutineScope example, does cancel method needs on onDestroy()?
    g
    • 2
    • 12
  • s

    Slackbot

    06/06/2019, 2:41 PM
    This message was deleted.
    e
    • 2
    • 1
  • m

    Mark

    06/06/2019, 2:48 PM
    I’ve been getting a strange intermittent error when executing
    CREATE INDEX
    SQLite statements in a coroutine (not using Room).
    SQLiteConnectionPool: The connection pool for database '+path+to+my_db' has been unable to grant a connection to thread 2676 (DefaultDispatcher-worker-8) with flags 0x2 for 12.003 seconds.
        Connections: 0 active, 1 idle, 0 available.
    It only ever (not always) happens if I call
    yield()
    in between each
    execSQL
    . Is it something to do with SQLite not liking being accessed by different threads within the same transaction (which I’m guessing might happen when using
    yield()
    )?
    a
    • 2
    • 2
  • u

    Uraniam9

    06/07/2019, 4:26 AM
    Can someone write copy to clipboard in kotlin code with text copied toast, I need in expandable child view menu fragment
    :google: 2
    d
    • 2
    • 1
  • j

    Johncarloespiritu

    06/07/2019, 12:05 PM
    hello there can someone help me here, im newbie in kotlin
    g
    f
    • 3
    • 2
  • p

    pavi2410

    06/07/2019, 5:39 PM
    Should I regret having refactored my app's every activity into fragments to use navigation architecture component? I read this: https://kotlinlang.slack.com/archives/C0B8M7BUY/p1551471716045900?thread_ts=1551471716.045900&amp;cid=C0B8M7BUY
    a
    m
    +3
    • 6
    • 10
  • s

    Sergey Burlaka

    06/09/2019, 8:04 PM
    Hi guys! Maybe almost every solve the problem to animate collapse avatar image in toollbar. https://stackoverflow.com/questions/31369842/collapsing-toolbar-layout-with-logo-title-subtitle-in-toolbar With usage Kotlin I have create the sample on github https://github.com/SergeyBurlaka/CollapsingAvatarToolbarSample and describe my sample on medium https://medium.com/@anatoliy8827/how-to-animate-collapsing-avatar-toolbar-sample-f3f37ab6c35e I have put my time and efforts because i want to has the dialog with android developers community when receive your feedback.
    r
    • 2
    • 2
  • a

    Animesh

    06/10/2019, 6:58 AM
    Can we get statics - how many user install my and but not open through Google analytics?
    :google: 5
    g
    • 2
    • 1
  • o

    Olivier Patry

    06/10/2019, 10:48 AM
    Hello all 👋 I have some difficulties using contacts
    ContentResolver
    query. I'd like to filter either by name or email in a single query. I tried
    CONTENT_FILTER_URI
    which helps filtering display name properly but can't combine with email lookup. Using
    CONTENT_URI
    to query non empty emails starting with a string gives poor results regarding display name matching (accented letters, first name / last name). Do you have some hints to combine both of two worlds in a single query?
    :google: 7
    r
    • 2
    • 3
  • f

    Fanzheyuan

    06/10/2019, 12:51 PM
    Does anybody have this problem? when I use safeargs classpath “android.arch.navigation:navigation-safe-args-gradle-plugin:$version_navigation” apply plugin: ‘androidx.navigation.safeargs’
    b
    • 2
    • 2
  • l

    lawlorslaw

    06/11/2019, 6:41 AM
    what is the best practice around using dates in Kotlin. Should we avoid using the Java Date or Calendar classes? What is the replacement for this? Are there any good blog posts around this topic?
    g
    m
    • 3
    • 7
  • t

    TheDukerChip

    06/11/2019, 7:06 AM
    Hey guys, for java in android
    enums
    are restricted to use because it takes a bit large memory

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

    Instead of
    enum
    android suggested to use the
    TypeDef
    according to the above video. Can we use the `enum`'s in kotlin or we should go with the any alternatives?
    🤦‍♂️ 6
    :dusty_stick: 2
    🇳🇴 1
    l
    c
    +5
    • 8
    • 17
  • v

    Vladimir Ivanov

    06/11/2019, 12:36 PM
    private suspend fun onLogin(login: String, password: String) { delay(100) Toast.makeText(this, "Hello from $login, my password is $password", Toast.LENGTH_LONG).show() } This block of code gives me an Internal Compiler Error using 1.3.0-compose-20190503: e: java.lang.IllegalStateException: Backend Internal error: Exception during code generation Cause: null while generating code for: FUN name:onLogin visibility:private modality:FINAL <> ($this:androidx.ui.material.demos.GithubActivity, login:kotlin.String, password:kotlin.String) returnType:kotlin.Unit [suspend] $this: VALUE_PARAMETER name:<this> type:androidx.ui.material.demos.GithubActivity VALUE_PARAMETER name:login index:0 type:kotlin.String VALUE_PARAMETER name:password index:1 type:kotlin.String BLOCK_BODY
    g
    • 2
    • 5
  • u

    Uraniam9

    06/11/2019, 3:07 PM
    Can someone help me in fixing this crash
    m
    • 2
    • 1
  • u

    Uraniam9

    06/11/2019, 3:07 PM
    https://del.dog/tohijozuvi.sql
    a
    • 2
    • 1
  • t

    TheDukerChip

    06/12/2019, 12:57 PM
    Can anyone here help me to get into the Android community slack? I've made request in http://android-united.community/ last week. but there is no response I know that this question isn't related to
    android/kotlin
    . But I don't know where else to ask this
    m
    a
    • 3
    • 3
  • w

    william

    06/12/2019, 4:34 PM
    does anyone use some type of delegate to hold onto referenced views in a weak fashion / null them out in
    onDestroy
    or something similar? the manual useage of a nullable view seems very un-kotlin
    t
    i
    • 3
    • 3
  • z

    zokipirlo

    06/13/2019, 6:11 AM
    Sorry, for asking offtopic but it's in channel title and don't know where to ask. Is Android United community working? Waiting for invite for quite a some time but nothing is happening...
    t
    m
    • 3
    • 3
  • e

    escodro

    06/13/2019, 9:32 AM
    Is there a way of Lint to detect when a class can be set as
    internal
    ? Similar to suggest when a class can be
    package-private
    in Java.
    u
    a
    • 3
    • 6
  • k

    K0NN4

    06/13/2019, 4:42 PM
    How can i reference the SongName variable in my other object?
    class MainActivity : AppCompatActivity() {
    
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
    
            SpotifyService.connect(this) {
                spotifyAppRemote?.let {
                    it.playerApi.subscribeToPlayerState().setEventCallback {
                        val track: Track = it.track
                        Log.d("MainActivity", track.name + " by " + track.artist.name)
                        ALabel.text = track.name
                        Blabel.text = track.artist.name
                        var SongName = track.name
                        var SongArtist = track.artist.name
                    }
                }
            }
            GeniusApi.PrintSomething()
        }
    }
    object GeniusApi {
        val BASE_URL = "<https://api.genius.com>"
        val SEARCH_URL = BASE_URL + "/search"
        var DATA = SongName@MainActivity
    
        fun PrintSomething() {
            Log.e("GeniusApi", DATA)
        }
    }
    t
    l
    • 3
    • 6
  • j

    Joao Birk

    06/13/2019, 5:59 PM
    if I look at the code being called we are doing: return NumberFormat.getInstance().apply { minimumFractionDigits = minPrecision maximumFractionDigits = maxPrecision roundingMode = RoundingMode.HALF_UP }
    :stackoverflow: 3
    a
    • 2
    • 3
  • g

    grzesiekmq

    06/14/2019, 5:45 PM
    hello is it possible to use Kotlin with Ionic UI framework. Maybe there is some solution or would be?
    r
    • 2
    • 1
  • k

    kevin.cianfarini

    06/14/2019, 5:46 PM
    if I'm using retrofit to make a call to a no content endpoint, should I set the return type of the function to be
    Call<Unit>
    or
    Call<Void>
    ?
    l
    g
    • 3
    • 7
  • a

    Allan Wang

    06/15/2019, 9:55 PM
    @BindingAdapter("android:languageColor")
    fun TextView.languageColor(color: String?) {
    Usage
    android:languageColor="@{repo.primaryLanguage.color}"
    I’ve verified that • TextView is the correct class (not appcompat) • Input is nullable (also tried
    Any?
    ) And I’ve tried the label as
    languageColor
    . The IDE correctly autosuggests the name, but I’m getting the error:
    ****/ data binding error ****msg:Cannot find the setter for attribute 'android:languageColor' with parameter type java.lang.String on android.widget.TextView.
    Edit: Also just checked and it works fine with java
    d
    g
    • 3
    • 3
  • t

    Tuan Kiet

    06/16/2019, 10:55 AM
    Not kotlin related but anyone know any good android open source repo to learn from. Get iosched as the baseline
    m
    • 2
    • 1
  • m

    myanmarking

    06/17/2019, 9:56 AM
    is there any way to force the compiler to ignore java null checks annotations for an override case ?
    g
    • 2
    • 10
  • m

    myanmarking

    06/17/2019, 9:59 AM
    public void clearView(@NotNull RecyclerView recyclerView, @NotNull ViewHolder viewHolder) {
          Intrinsics.checkParameterIsNotNull(recyclerView, "recyclerView");
          Intrinsics.checkParameterIsNotNull(viewHolder, "viewHolder");
          super.clearView(recyclerView, viewHolder);
          ...
       }
    t
    • 2
    • 1
Powered by Linen
Title
m

myanmarking

06/17/2019, 9:59 AM
public void clearView(@NotNull RecyclerView recyclerView, @NotNull ViewHolder viewHolder) {
      Intrinsics.checkParameterIsNotNull(recyclerView, "recyclerView");
      Intrinsics.checkParameterIsNotNull(viewHolder, "viewHolder");
      super.clearView(recyclerView, viewHolder);
      ...
   }
t

tseisel

06/17/2019, 11:54 AM
Because
clearView
parameters are annotated with
@NonNull
, the Kotlin compiler overrides then as non-null. For Java interop, any function that can be called from Java code is protected by those
intrinsics
checks. Maybe you could file a bug for that AndroidX library, as the non-null constract is violated. As a workaround, try setting those parameters as nullable in Kotlin: this should remove the intrinsics checks.
View count: 5