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

    ZariApps

    08/11/2020, 5:41 PM
    override fun onCreateOptionsMenu(menu: Menu?): Boolean {
        val inflater = menuInflater
        super.onCreateOptionsMenu(menu)
        inflater.inflate(R.menu.main_menu, menu)
    
        val manager = getSystemService(Context.SEARCH_SERVICE) as SearchManager
        val searchItem = menu?.findItem(R.id.search)
        val searchView = searchItem?.actionView as SearchView
        searchView.setSearchableInfo(manager.getSearchableInfo(componentName))
        searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
            override fun onQueryTextSubmit(query: String?): Boolean {
                searchView.clearFocus()
                searchView.setQuery("", false)
                searchItem.collapseActionView()
                Toast.makeText(this@MainActivity, "looking for $query", Toast.LENGTH_LONG).show()
                return true
            }
    i have this in the main activity. if I want to reuse this(it's a search bar on the actionbar) in another activity, do i have to copy and paste the code every time? or is there an easier/efficient way to do this?
    s
    i
    c
    • 4
    • 59
  • b

    Brendan Weinstein

    08/11/2020, 8:02 PM
    hey anyone know if there's a way to get a DialogFragment (Bottom sheet DialogFragment) to be the root of a modal flow? Meaning I don't want it to be dismissed when I navigate from it to another fragment
    i
    b
    • 3
    • 3
  • j

    Jonny

    08/12/2020, 5:51 PM
    I'm wondering how to dependency inject into a feature module. All of the examples I see uses an activity. Is it not possible to use a feature module without a separate activity? From what I've seen you can just navigate by single-activity navigation and specify which module a certain navigation action goes to. I can't figure out how to get dagger working though. This is in one of my modules.
    @Singleton
    @Component(
        dependencies = [AppComponent::class],
        modules = [
            ViewModelModule::class,
            FragmentModule::class
        ]
    )
    interface StartupComponent : AndroidInjector<BaseApplication> {
        fun inject(activity: MainActivity)
    }
    But I have nowhere to initialize this component from. This is the error that I get:
    No injector factory bound for Class<ferm.jonny.startup.presentation.fragments.ExtendedSplashScreenFragment>
    c
    • 2
    • 3
  • o

    Olajide Awoyinka

    08/13/2020, 1:39 AM
    Hi everyone 👋 I'm trying to make my app hit my server which consists of the FCM api endpoint, every weekly or monthly based on the user preference, but I don't really know how to go about it, I figured the operation would be a background task but I'm stuck at what I need to use cos AlarmManager would only achieve it for an exact time hour you fixed. So anyone with any article or guide would really appreciate
    c
    • 2
    • 1
  • j

    Joey

    08/13/2020, 2:20 AM
    Anyone encountered UI with Grouped recyclerview and the section items are single option? Could find any helpful resource. If you know something hit me up. Thanks!
    a
    • 2
    • 1
  • c

    Christopher Elías

    08/13/2020, 7:27 AM
    Hello, im having an issue with Kotlin Flow and Room. Im trying to return a Flow of a Tupple data class(https://developer.android.com/training/data-storage/room/accessing-data#query-subset-cols). But the compiler throw this error:
    WalletDao.java:11: error: Not sure how to convert a Cursor to this method's return type
    Has someone experienced something like this?
    g
    a
    • 3
    • 7
  • m

    myanmarking

    08/13/2020, 9:21 AM
    i mean, like observing from two tables and joining the data
    g
    • 2
    • 1
  • s

    Sam

    08/13/2020, 1:52 PM
    Good evening everyone, I have spend the whole week to read telegram code, but I still have no idea how they can handle the keyboard and edit text very smooth, correct height. Does anyone know what their solution is? I have tried : windowsoftinputmode = adjust_resize but Im still see blink not smooth windowsoftinputmode = adjust_nothing and popup window to getting keyboard's height but it's not work to get correct keyboard's height when choose emoji , search gif on google keyboard Thanks.
    20200813_204538.mp4
    g
    • 2
    • 12
  • g

    gabrielfv

    08/13/2020, 6:41 PM
    Hello, I’ve been trying to move common details of my android lib modules to a specific plugin defined in
    buildSrc
    . Using Kotlin along with the
    kotlin-dsl
    for gradle i’ve been able to move pretty much everything except for the following excerpt:
    android {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }
    The
    kotlinOptions
    isn’t visible from the extensions within
    buildSrc
    sourceset, probably because I don’t implement the dsl? I’ve tried doing the following, but it didn’t work
    target.tasks.withType(KotlinCompile::class.java).forEach { task ->
        task.kotlinOptions.jvmTarget = "1.8"
    }
    i
    • 2
    • 4
  • s

    samuel

    08/14/2020, 12:50 AM
    I have a question related to passing touch event from a dialog fragment to the activity below (parent activity). My goal is to be able to have the dialog showing but allow the transparent section of the dialog to pass touch events back to the parent activity so that other things like clicks/ keyboard input can still happen as the dialog is being shown. Currently i am using
    dialog?.window?.decorView?.setOnTouchListener { view, motionEvent ->
        activity?.dispatchTouchEvent(motionEvent)
        false
    }
    to try to dispatch the touch event to the activity but it doesn’t work as i expected. Does anyone have an idea of how to approach this?
    z
    i
    • 3
    • 9
  • i

    Isaac

    08/14/2020, 3:10 PM
    Anybody know how to show an empty state view if PagingData has empty items? I can't seem to check the size of the items in PagingData
    d
    • 2
    • 4
  • v

    Vincent Williams

    08/14/2020, 5:42 PM
    anyone know if theres a way to pass args into the constructor of a fragment using the navigation component? I have a VehicleFragment that should take a vin. I know I can pass it in via a bundle but was wondering if constructor args are possible with the nav component
    i
    • 2
    • 18
  • c

    colintheshots

    08/14/2020, 6:05 PM
    Embarrassing I don't know this, but if I want to use the newly stable Kotlin 1.4.0 explicit API mode with Android build.gradle, where would I put the block?
    kotlin.explicitApi()
    z
    r
    c
    • 4
    • 22
  • m

    manlan

    08/14/2020, 7:41 PM
    Is `await`ing in fragment A for a computation done in another fragment B possible in anyway? I know this is a dumb question, but I'm finding it hard to chain a sequence of asynchronous operations.
    Untitled
    c
    b
    i
    • 4
    • 19
  • i

    itnoles

    08/14/2020, 8:51 PM
    Does AGP 4.0 and 4.1 supports Kotlin 1.4?
    z
    • 2
    • 1
  • j

    jnyakush

    08/15/2020, 9:48 AM
    I have this bug I updated my old project which I used Kotlin DSL last year I was using Android studio 3.5 at that time I have changed gradle all versions to recent once even kotlin version 1.3.7* I can't pass this error if anyone encountered help me out kindly Forgot to say it has dynamic modules in it
    9fe11ddd-02a4-45bd-8d47-5ba586f45d2a
    • 1
    • 1
  • n

    Nikola Milovic

    08/15/2020, 6:05 PM
    Any reason why
    emit
    says it has to be ran from a coroutine body ( I am well aware it is a suspend function)?
    import kotlinx.coroutines.flow.Flow
    import kotlinx.coroutines.flow.flow
    
    class FirebaseDataSource (private val firebaseFirestore: FirebaseFirestore) : NetworkDataSource{
    
        fun fetchMenuItems(): Flow<Food> = flow{
            firebaseFirestore.collection("menu_items")
                    .get()
                    .addOnSuccessListener { documents ->
                        try {
                            for (document in documents) {
                                val doc =...
                                emit(doc) //error here
                            }
                        } 
                    }
        }
    In every example I've seen online they have it just inside the
    flow {}
    Eg.
    fun simple(): Flow<Int> = flow { 
        for (i in 1..3) {
            delay(100)          
            println("Emitting $i")
            emit(i)
        }
    }
    t
    a
    +2
    • 5
    • 5
  • m

    Mohamed Elfiky

    08/16/2020, 8:52 AM
    any one know why when using registerForActivityResult in BottomSheetDialogFragment the ide say Unresolved reference: registerForActivityResult error but it runs fine
    t
    b
    • 3
    • 11
  • n

    Nikola Milovic

    08/17/2020, 12:15 PM
    Hey! Got a problem and I cant think of an elegant and clean solution. Basically in a mutli feature (module) project I have a restaurant Menu feature and an Order feature to preview and confirm the selected items. The problem lies in notifying the Feature Order about adding a new item while keeping them decoupled as much as possible. You select an item from the Menu and it should give a notice or something to the Order module. Single activity, bottom nav bar so cannot use the fragment arguments. Modules are VMs,Fragments and their data layers.
    d
    • 2
    • 3
  • e

    Eugene

    08/17/2020, 2:27 PM
    Good day to all! 🙂 My name is Eugene and I'm a product manager at JetBrains. Currently, I look for Java developers who continue to use Java in their production projects. I'd like to learn more about your UCs and why's do you use Java instead of Kotlin. I think most of you have completely switched to Kotlin, but perhaps you know people out of this channel who continue to use Java 🤔 Just DM me and I'll ask a few questions :android: That's it. Have a nice day and happy coding 👩‍💻
    :java: 3
    👋 3
    a
    c
    • 3
    • 2
  • d

    Daniele B

    08/17/2020, 8:58 PM
    class AppViewModel : ViewModel(), LifecycleObserver {
    
        val myCoreModel = MyCoreViewModel()
    
        @OnLifecycleEvent(Lifecycle.Event.ON_START)
        fun onStart() {
            myCoreModel.appEnteredForeground()
        }
    
        override fun onCleared() {
            super.onCleared()
            myCoreModel.appWillClose()
        }
    
    }
    How can I capture, from within the Android’s ViewModel, the event of the app entering the foreground? I tried this way, but my function
    appEnteredForeground
    doesn’t get fired.
    f
    • 2
    • 1
  • a

    Aditya

    08/17/2020, 11:12 PM
    When launching a share intent, is it possible to know when it is complete? I want to move on after the user has seen the share dialog, but not until it has been dismissed
    a
    • 2
    • 2
  • p

    Paul Woitaschek

    08/18/2020, 7:07 AM
    Am I missing something or is the kotlin 1.4.0 plugin for android studio not released on the stable track yet?
    j
    a
    o
    • 4
    • 11
  • e

    Eugen Martynov

    08/18/2020, 7:28 AM
    After 1.4 update our build started failing with
    Caused by: java.lang.IllegalStateException: Unexpected non-class file: META-INF/versions/9/kotlin/reflect/jvm/internal/impl/serialization/deserialization/builtins/BuiltInsResourceLoader.class
    Any ideas people what could be the cause?
    🍿 2
    m
    • 2
    • 2
  • s

    siz

    08/18/2020, 10:24 AM
    what is the best way to get Object returned from a CoroutineWorker • sth like Result.Success(object)
    o
    • 2
    • 1
  • m

    Mohamed Elfiky

    08/19/2020, 1:17 AM
    what is the correct way to use viewBinding in coustom view mainly extending ConstraintLayout or should i avoid it and use findViewById?
    g
    f
    j
    • 4
    • 4
  • m

    manlan

    08/19/2020, 9:22 AM
    How do I setup a count-up timer that runs even if app is killed?
    m
    • 2
    • 5
  • t

    tseisel

    08/19/2020, 4:34 PM
    I'm having issues with Android Studio not reusing my Gradle daemons. Which JDK are you using to build Android applications ? :java: Oracle JDK ☝️ Another one (please tell me in comments!) Also, which version do you use ? 8️⃣ JDK 1.8 1️⃣ JDK 11 ➕ JDK 13+
    ☝️ 1
    ➕ 4
    8️⃣ 15
    g
    k
    • 3
    • 5
  • j

    Ju

    08/19/2020, 4:34 PM
    1.8
    t
    a
    • 3
    • 4
  • s

    Slackbot

    08/19/2020, 6:06 PM
    This message was deleted.
    o
    c
    • 3
    • 2
Powered by Linen
Title
s

Slackbot

08/19/2020, 6:06 PM
This message was deleted.
o

okarm

08/19/2020, 6:17 PM
If you yourself recognize that it's not Kotlin related, why do you pollute the Kotlin slack? I recommend checking out https://d.android.com
c

Casey Brooks

08/19/2020, 6:37 PM
It’s not designed to be a general Android support channel, but for “Using Kotlin to build Android applications.” There are other Slack channels for that, such as http://android-united.community/ as listed in this channel’s description
View count: 13