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
stackoverflow
  • u

    user

    07/01/2022, 11:51 AM
    Navigation drawer below TopAppBar in Jetpack Compose I am using Jetpack Compose for developing one app which contains multiple screens and we can navigate to them using Navigation Drawer. How can I put my navigation drawer below TopAppBar ( or Toolbar in Android). Below is the gif for the issue:

    https://i.stack.imgur.com/4H7Jj.gif▾

    Below is the composable function for my screen: fun Home(navController: NavHostController) { val scaffoldState = rememberScaffoldState() val coroutineScope...
  • u

    user

    07/01/2022, 11:51 AM
    How to implement setText to integer dataType in Kotlin?

    I want to set data from my editText which has integer typedata. if it is string, we can make setTake, but how we can implement it at integer?▾

  • u

    user

    07/01/2022, 12:31 PM
    How to prepopulate realm file in Kotlin SDK? In Java SDK, I was creating Realm.Configuration object with the realm file that located in asset folder. I couldn't find any equivalent property in Realm Kotlin SDK in java SDK: val populatedRealmConfiguration = RealmConfiguration.Builder() .schemaVersion(REALM_VERSION) .compactOnLaunch() .encryptionKey(resolveEncrypt(RealmHelperStatics.EncRealmKey).toByteArray()) .assetFile("populated.realm") .name("populated.realm") .allowQueriesOnUiThread(true)...
  • u

    user

    07/01/2022, 1:11 PM
    How to get a list of classes that extend from a base class in Kotlin? consider following classes structure in Kotlin: open class Base { ... } class A : Base() { ... } class B : Base() { ... } ... class Z : Base() { ... } How would I go around getting a list of ALL classes (A-Z in this particular example) that inherit from Base class? I tried using reflection with BaseTest::class.nestedClasses and other reflection properties but they don't seem to be finding number of extending classes properly.
  • u

    user

    07/01/2022, 1:51 PM
    Dagger2 & Kotlin: lateinit property has not been initialized I trying to inject presenter using Dagger, but I get an error: lateinit property loginPresenter has not been initialized. I can't find what I may be doing wrong. See the code above from my classes. This is the first time I'm facing this problem. LoginActvity.kt package com.xsavzh.vkfriends.activities import android.content.Intent import android.os.Bundle import android.view.View import android.widget.Button import android.widget.TextView import android.widget.Toast import...
  • u

    user

    07/01/2022, 2:31 PM
    How to convert png or jpg to webP using kotlin code? I want to write a kotlin code that converts png or jpg to webP.
  • u

    user

    07/01/2022, 2:31 PM
    I am learning Android studio and doing a rectangle calculator, my kotlin has 19 errors and cannot figure it out I am learning Android studio and doing a rectangle calculator. My Kotlin has 19 errors, and I cannot figure it out. I keep getting unresolved errors for btn, functions that cannot be called, and expecting an element. I am trying to do a calculator that takes height and width and then calculates area and perimeter. Just need guidance on what I am doing wrong and not looking for someone to give me new code. MainActivity.kt package com.example.calculator import android.annotation.SuppressLint...
  • u

    user

    07/01/2022, 2:31 PM
    Can pass data from View to ViewModel? Is there mistake if I pass data from View to ViewModel? For example, pass url from onPageFinished event of WebView. I am confused because all source tell that ViewModel mustn't have any link to View. In this case will be such link or not? Or if type of argument will be custom data class than just string? class MainActivity : AppCompatActivity() { private lateinit var binding: ActivityMainBinding private val viewModel: MainViewModel by viewModels() override fun...
  • u

    user

    07/01/2022, 2:31 PM
    How get updated value between dialogFragment and Fragment? I'm have Fragment and DialogFragment, they have own viewmodel's. After click "Ok" in dialogFragment call method, that update record in DB and return result to parentFragment, but navigate to parentFragment work faster then update DB, and list not updated. Now i just use sleep(500), to wait updated value, how fix that? Fragment class EmployeesFragment :...
  • u

    user

    07/01/2022, 2:31 PM
    How to notify adapter if the fragment deatched or destroyed [needed for Admob NativeAd AdViewHolder] In my app, I have implemented ad mob native ads inside my PostAdapter class, I have 7 different fragments, and I need to know when the fragment is detached or destroyed to call nativeAd.destroy() to avoid leaks like said in the documentation Be sure to use the destroy() method on loaded native ads. This frees up utilized resources and prevents memory leaks. so my trying to solve this problem, I...
  • u

    user

    07/01/2022, 2:51 PM
    Android WorkManager getting reference to Worker class I'm facing following problem: there's my class which inherits CoroutineWorker. Logic of this worker is complicated enough, in fact doWork() calls bunch of other routines inside and catches (collect) results of several StateFlows, like: override suspend fun doWork(): Result { //blah-blah withContext(Dispatchers.Default) { _scanResultState.collectLatest { //blah-blah } } return ... } Questions: Can I somehow return/put...
  • u

    user

    07/01/2022, 3:31 PM
    Kotlin handle a different type in constructor lets say that for an example I have a data class that's like this data class AB(a: String, b: String) how do I make a constructor (or if there is any other way) handle a different type, for example if get an "a" variable as an Int and I want to handle it and covert it to a string? Thanks!
  • u

    user

    07/01/2022, 3:51 PM
    Where does Spring Webflux create a coroutine scope when using suspend functions? This is a question about how Spring Webflux works under the hood. When we build our Spring Webflux application in kotlin we can use suspend functions and interfaces like CoroutineCrudRepository to ‘get rid of’ abstractions such as Mono and Flux. However, we do not need to explicitly create a coroutine scope somewhere so it seems that Spring takes care of that. Where does Spring create this coroutine scope? I would guess that a new scope is created when a request comes in and Spring then...
  • u

    user

    07/01/2022, 3:51 PM
    Firebase Vision confusing characters I'm using Firebase Vision, from MLKit, together with CameraX for text recognition in Android. The problem is that the results are not very consistent. Depending on the font, these recognitions may vary. For example, sometimes it's confusing the character 'b' with the digit '6'. This is not a problem if you only need digits in your result. But sometimes it's confusing digit '7' with digit '1', which is quite annoying for a digit detector. Is there any way to improve these results? Larger...
  • u

    user

    07/01/2022, 4:11 PM
    How to send Array Int as Request Body in Retrofit? How to change array of int to request body?

    Request Body▾

  • u

    user

    07/01/2022, 4:31 PM
    Get current time in Unix Timestamp Kotlin? How can I get current time in Unix Timestamp format in kotlin as integer?
  • u

    user

    07/01/2022, 4:31 PM
    Map get with null key I'm confused by Kotlin's null safety features when it comes to maps. I have a Map. Yet I can call map.get(null) and it returns null to indicate that the key is not present in the map. I expected a compiler error, because map is a Map and not a Map. How come I can pass null for a String argument? And a related question: is there any type of Map, be it a stdlib one or a third-party implementation, that may throw NullPointerException if I call get(null)? I'm wondering if it is safe to call...
  • u

    user

    07/01/2022, 4:31 PM
    Unresolved reference when trying to check if textfield is focused I have some weird behaviour with FocusState in compose. I get this error Unresolved reference: isFocused when using FocusState.isFocused in this code (However I can use it elsewhere). Here is my code: @Composable fun SearchBar( modifier: Modifier = Modifier, hint: String = "", onSearch: (String) -> Unit = {} ){ var text by remember { mutableStateOf("") } var isHintDisplayed by remember { mutableStateOf(hint != "") } Box(modifier = modifier){...
  • u

    user

    07/01/2022, 4:31 PM
    Vert.x Web API Service codegen and Kotlin, issue with nested properties of referenced object I'm trying to generate Web API Service from yaml openapi: 3.0.1 info: title: "" description: '' license: name: Apache 2.0 url: http://www.apache.org/licenses/LICENSE-2.0.html version: 1.0.0 servers: - url: http://localhost:3001 tags: - name: user description: Operations with users - name: stream description: Operation with streams paths: /user/register: post: x-vertx-event-bus: user_manager.myapp tags: - user summary: Create user...
  • u

    user

    07/01/2022, 5:11 PM
    Android - how to create file object from Imageview image Im making and android app which let the user select an image from the phone and load it to an ImageView. The further process is to send the image as a POST request to a PHP script It all works fine if I load the image to a File object from the file location, but this require that the user open a setting on the phone which allow the app to access and manage local files.. So, is there a way to read the image from the imagview into a File object? This is my current working code val fil =...
  • u

    user

    07/01/2022, 5:11 PM
    TextView text not showing text While Running app I have created a Horoscope app using an API in kotlin. Everything is working fine but the text view is not showing any text. And here is my XML Code.
  • u

    user

    07/01/2022, 5:31 PM
    What scope to use for launching a task in Kotlin from a controller? My Kotlin App is using Spring to expose an API that should execute a long task in the background. We need to return @PutMapping("/refresh") fun refresh() = { GlobalScope.launch(IO) { refreshDataFromCache() } return ResponseEntity.accepted().body("""{"result": "accepted"}""") } IntelliJ complains that using the GlobalScope is an anti-pattern. However, I cannot just add suspend to the controller function or it won't work. Neither I can use runBlocking or the method will need to wait...
  • u

    user

    07/01/2022, 5:31 PM
    How to take backup locally of my Android App in Android Studio I m new to Android Dev. I have built an app(yet not released on play store) and thinking to add new features to it. But i m not confident enough and I think I might make mistakes and my app might get worse. How to I create a local backup of my android app? Should I just copy the files in which I set my projects to another location or there is another method?
  • u

    user

    07/01/2022, 5:51 PM
    How to show Multiple color text in same Text view with Jetpack Compose? I want to display text in multiple colors/style within same Text() component. How can i achieve this using Jetpack Compose? Sample:

    https://i.stack.imgur.com/ATJxI.png▾

  • u

    user

    07/01/2022, 6:11 PM
    How to return data from inside of addOnSuccessListener{} method in Kotlin? I am trying to get user data from Firebase Firestore database , I am intended to get info of user who is currently logged in. Now for make this information accessible from other Classes I created get method for username and email, when I used get method from Another class , I got an indexOutOfBoundsException with index 0,size 0. It looks like my array in global scope is not getting data when i called array.add() method from addOnSuccessListener method. package...
  • u

    user

    07/01/2022, 6:11 PM
    Jetpack Compose: Textfield doenst lose focus on click outside of it I am trying to implement a searchbar in my Compose app. I have a textfield, which I want to lose focus of and hide the keyboard, when I click outside of the textfield. However, I can't figure out how to do it. I did try to do it this way, which I saw on github. However, i did some changes. The original solution used this part of code isHintDisplayed = it != FocusState.Active which seem to be deprecated. So I changed it to isHintDisplayed = it.isFocused != true which should...
  • u

    user

    07/01/2022, 7:31 PM
    Composable fillMaxSize and rotation not working How can I rotate composables and still make them fill their parent? For example, I have a Column filling the Screen with two Boxes taking up half the size. The size of the boxes seems to be calculated before the rotation and not after. Column( modifier = Modifier .fillMaxSize() .padding(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp) ) { Box( modifier = Modifier...
  • u

    user

    07/01/2022, 7:51 PM
    How to fix animation bug? I have a VideoView (circle) and custom animation (Falling cards) on the screen, in Fragment, as in the screenshot:

    https://i.stack.imgur.com/p8YES.png▾

    I haven't figured out how to do it any other way, so I've inserted four CardViews, and I'm scrolling through them using AnimationUtils. In code it looks like this: onViewCreated() viewLifecycleOwner.lifecycleScope.launch { // withContext(Dispatchers.Main) { startAnimation() //...
  • u

    user

    07/01/2022, 8:11 PM
    Can a coroutine suspend and then resume on a different thread? Are the memory effects of the first thread carried to the second thread? Consider fun main(args: Array) { runBlocking { launch(Dispatchers.Default) { var a = 0 a++ delay(100) println(a) } } } Since the Dispatcher has multiple threads, is it possible for the program to change threads at the suspending delay function? Is it guaranteed that it will print '1' or does a need to be AtomicInteger?
  • u

    user

    07/01/2022, 9:51 PM
    How To send request with different body to an Api with paging3 kotlin Hi I have a function inside my viewModel which make a pager and return a flow: fun loadLastMoviesList(genreId: Int) = Pager(config = PagingConfig(10)) { LastMoviesPaging(repository, genreId) }.flow.cachedIn(viewModelScope) and a click listener in my HomeFragment which whenever user click it execute the function with different genreId: genresAdapter.setOnItemClickListener { genre, name -> lastMoviesTitle.text = "$name Movies" genre.id?.let { id ->...
Powered by Linen
Title
u

user

07/01/2022, 9:51 PM
How To send request with different body to an Api with paging3 kotlin Hi I have a function inside my viewModel which make a pager and return a flow: fun loadLastMoviesList(genreId: Int) = Pager(config = PagingConfig(10)) { LastMoviesPaging(repository, genreId) }.flow.cachedIn(viewModelScope) and a click listener in my HomeFragment which whenever user click it execute the function with different genreId: genresAdapter.setOnItemClickListener { genre, name -> lastMoviesTitle.text = "$name Movies" genre.id?.let { id ->...
View count: 6