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/19/2022, 1:21 PM
    RecyclerView is not showing results and freezes when using getFilter I'm trying to create a simple dialog where only a SearchView is shown and once the user starts writing it will filter some data from DB and will return only items which matches that search. The issue is that once i start writing and if i type fastly the APP just freezes but even if i go slow the RecyclerView doesn't return any result even if mList is not empty. Here is my Adapter code: class AdapterRicerca( private val mListAll: ArrayList, private val callback: RicercaCallback ) :...
  • u

    user

    07/19/2022, 1:21 PM
    The onItemChangeListener crashes So I am currently working on a spinner that changes entries in a list. When loading into the Fragment and loading the List into the spinner adapter and setting up the onItemChangedListener everything works fine. But when the App goes to another Fragment and then goes back the app crashes with the following exception: E/AndroidRuntime: FATAL EXCEPTION: main Process: de.heffnersoftware.hsproduction, PID: 13111 java.lang.NullPointerException: Parameter specified as non-null is null: method...
  • u

    user

    07/19/2022, 1:41 PM
    Android Studio Kotlin Recyclerview how to do multiple type view for specific object feature? I have data from RickandMorty Api and saving them on CharacterList and I am showing them in a recyclerview.I have name,location and status informations and showing them in cards.I have another carditem for displaying dead users and I want to show Alive persons in default card and Dead persons in another carditem (Default Carditem with blue backgroundcolor and other carditem is with red backgroundcolor).So as my researches people handle that with getItemViewType() but in my case I want to...
  • u

    user

    07/19/2022, 1:41 PM
    How does this compile without errors? fun main() { val list = listOf(5, 3, 4, 11, 6) print(test(1, "abc", 4)) } fun test(criteria: T, actual: T, points: Int): Int { if (criteria == null) return 0 return if (criteria == actual) points else 0 } // prints 0 The arguments provided in main function does not match generics contract in the test function. How does this compile? Tested with Kotlin 1.7.10, here's the kotlin playground link: <a href="https://pl.kotl.in/s9fJVUw0D" rel="nofollow...
  • u

    user

    07/19/2022, 2:01 PM
    Can't solve error regarding 'org.codeaurora.qcamera3.exposure_metering.exposure_metering_mode' I am working on an android application with AR elements. When it is redirecting me from the onboarding screen to the AR screen it crashes with the following error. java.lang.IllegalArgumentException: Could not find tag for key 'org.codeaurora.qcamera3.exposure_metering.exposure_metering_mode') at android.hardware.camera2.impl.CameraMetadataNative.nativeGetTagFromKeyLocal(Native Method) at...
  • u

    user

    07/19/2022, 2:01 PM
    how to get actual path of a file picked in jetpack compose? how to get actual path of a file picked in jetpack compose and upload in via retrofit.i had tried to get path via content resolver but it returning "ERROR: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is correctly initialized before accessing data"
  • u

    user

    07/19/2022, 2:01 PM
    How to move the image as transparent after erasing background to other screen? I'm developing a photo editing app, in that I have a feature to add the image to other image as transparent after editing in the app. So I can able to erase the background of the image. But I don't know how to move the background erased image to other screen , like how we do for the normal image. Now if I move the transparent part appeared as grey part. you can see that image. Help me to solve this. Thank you. [ Canvas( modifier = drawModifier...
  • u

    user

    07/19/2022, 2:01 PM
    How to add indication for compose Modifier.mouseClickable? In jetpack compose Modifier.clickable adding hover and click effect, however Modifier.mouseClickable doesn't provide this.

    https://i.stack.imgur.com/kfzuk.jpg▾

    On screenshot internal modifier from Modifier.clickable and mouseClickable, I think indication = null is the reason why there is no effect on click. By the way Modifier.indication doesn't work or I use it wrong.
  • u

    user

    07/19/2022, 2:21 PM
    GreedyScheduler.onAllConstraintsMet ANR Anyone able to help with this one. Nothing in stack trace helps to track down the source of the problem as there is absolutely no reference to our app it self. And it only happens on Android 12. I completely lack to understand what java.util.Currency has to do with our app at all... #00 pc 0x458f1c libart.so #01 pc 0x6f98a8 libart.so #02 pc 0x701380 libart.so #03 pc 0x3b38c0 libart.so #04 pc 0x34a314 libart.so #05 pc 0x762bd0 libart.so at java.lang.System.arraycopy(Native...
  • u

    user

    07/19/2022, 2:21 PM
    How would I map a list of items to another function? I am trying to figure out the best way to map. This is an example of what I have. data class ValueDescription (val length: Int, val count: Int) // Now I am trying to map to a variable that looks like this val myValues = ValueDescription(length here_, count here) I have a sorted map that I want to map to my values // The map will look like this // Where both Ints hold the lengths and counts // For example I would have the length of 7 to count of 8 val out = Map How can I take the...
  • u

    user

    07/19/2022, 2:21 PM
    Calling a function every 20 seconds in kotlin There is a function I'm trying to call every 20 seconds using Timer(). I already tried as well with a while loop followed by a delay of 20 seconds, but ends up running out of memory or throws thread exceptions. How can I do this without making my app crash and run out of memory? For a matter of context, I'm building an app to communicate with a BLE device. I just started with Kotlin, so I'm not sure how to do this without breaking everything. I just want call the same function because...
  • u

    user

    07/19/2022, 2:41 PM
    How to show notifications at provided time frame and frequency in Android? I'm trying to make a feature where user can select the time frame and interval in which he would receive notifications to his phone. I'm using AlarmManager for repeating notifications, however it only covers the start time of notifications and the interval/frequency of notifications. How could I make the notifications go off only from user selected hours, let's say every day 1 PM - 8 PM (13:00 - 20:00) every 2 hours? I was thinking about using WorkManager to start AlarmManager at selected...
  • u

    user

    07/19/2022, 2:41 PM
    KSP: how can I get the default value of a data class property? I have the following data class annotated with @MyAnnotation: @MyAnnotation data class MyDataClass( val foo: Boolean = true, val bar: Int = 123, val buz: String? = "abc", ) From the ClassDeclaration I can get all the KSPropertyDeclaration, and I'm able to get the simpleName and resolve the KSType, but I don't know how to get the default values of each property.
  • u

    user

    07/19/2022, 3:01 PM
    Migration from SQLite Cipher V1 to Room DB V2 on App Update: I build two apps with the same package name: In the first app, I use SQLiteCipher using "Pass_Phrase" (Version_1 DB) for CRUD operations using Java. In the second app, I just wanted to migrate from SQLiteCipher to Room (Version_2 DB) and also read data from SQLiteCipher and put it into Room DB using Kotlin. I completed the first app and was stuck at migration's step in the second app. Need your help. Thanks a lot!
  • u

    user

    07/19/2022, 3:01 PM
    The same value, 16, was passed as the prevKey in two sequential Pages loaded from a PagingSource I have this pager with Paging 3 that keeps either repeating pages (if I allow keyReuseSupported) or returning the IllegalStateException because of "The same value, 16, was passed as the prevKey in two sequential Pages loaded from a PagingSource." I am not sure why this is happening, even if I do understand the theory. This is the paging data source: override suspend fun load(params: LoadParams): LoadResult { val key = params.key ?: parseDateFrom(date) return runCatching {...
  • u

    user

    07/19/2022, 3:01 PM
    Why is the recycler view has NullPointerException in fragment? so here is the code for my recycler view adapter, which is located at onCreate: override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) databaseReference = FirebaseDatabase.getInstance().getReference("profilUsaha") auth = FirebaseAuth.getInstance() uid = auth.currentUser?.uid.toString() daftar_pesan_recycler_view.adapter = adapter listenForLatestMessages() arguments?.let { param1 = it.getString(ARG_PARAM1) param2 =...
  • u

    user

    07/19/2022, 3:21 PM
    How to change the Permission Handler old version to the new version i have the old permission handler code, but i'm using the latest version of pubspec.yaml . how to change the code below with the latest version?? is there someone who can help me if (Platform.isAndroid) { PermissionStatus permissionStorage = await PermissionHandler().checkPermissionStatus(PermissionGroup.storage); if (permissionStorage != PermissionStatus.granted) { Map permissionStatus = await PermissionHandler().requestPermission([PermissionGroup.storage]);...
  • u

    user

    07/19/2022, 3:41 PM
    Android Studio: autoSize of EditText doesn't work in my current project there's an EditText with fixed layout_width and layout_height, called exercise that is expanded downwards programmatically: One line of text (String) + "\n" is added to the EditText. Sometimes the line added to the EditText, let's call it element, is too long to fit inside the full width of the object so it's splitted into a new line. The thing is I would either like the lines' text size in exercise to be resized to fit the EditText's width or have a clear visible...
  • u

    user

    07/19/2022, 3:41 PM
    Android Jetpack Compose Animation of Size Change with Duration How do I add duration to content size change animation in Jetpack Compose? Trying to use Modifier.animateContentSize() and pass an animationSpec with duration, but it just snaps in or out, duration is not observed. Column() { Modifier.animateContentSize (animationSpec = tween(durationMillis = 5000, easing = LinearEasing)) if (!isTabInvisible) { //some content goes here } }
  • u

    user

    07/19/2022, 4:21 PM
    In Kotlin, can I have a conditional builder element on a collection? Currently I have a query that looks something like this: override suspend fun getExternalTestsForProfile(profileKey: String, take: Int?): List { RealmDb.useRealm { where(RealmExternalTest::class.java) .sort(RealmExternalTestFields.CREATED_AT, Sort.DESCENDING) .findAll() I want to have functionality so that if take is null, it will fetch all elements in the collection, but if an Int is supplied, it will take and map in that case only. So my...
  • u

    user

    07/19/2022, 4:41 PM
    How reload app from Android Studio with Foreground Service running? I'm new to Android development. We have an app where a Foreground service gets kicked off when the app boots. The service is all good and working well. When debugging an app without a Foreground Service in Android studio was easy...you find the app in the Recents list, kill it, and then hit the "Play" button to Run your app with the most recent changes. The problem is when killing the app, the Foreground Service is still running so clicking the play button just sits there with a progress bar...
  • u

    user

    07/19/2022, 4:41 PM
    MongoDB exception DuplicateKey while saving I have a simple method to update my object fun updateUniversity(university: University): Mono { if (university.id == null) { return Mono.empty() } return universityRepository .findById(university.id!!) .filter { it.name == university.name } .map { university.copy() } .flatMap { universityRepository.save(it) } } and it fails on saving the result (org.springframework.dao.DuplicateKeyException). But saving is not only about creating...
  • u

    user

    07/19/2022, 5:01 PM
    Multiple Animations are Not Launching At the Same Time in Jetpack Compose I have 3 animations, but the top one launches first, then the other two, how do I get them all to launch at the same time? I tried putting them in the same coroutine scope but still getting same results. LaunchedEffect(isItemInView) { scope.launch { coroutineScope { launch { // Even without the scope.launch, coroutineScope, launch lines, same effect bar1.animateTo(if (isItemInView) bar1EndLocation else bar1StartLocation)...
  • u

    user

    07/19/2022, 6:01 PM
    Round the Integer value with specific steps increment and decrement (please read carefully) Kotlin [closed] I'm using Kotlin language. I have 2 scenario increment/decrement: var slotValue = 500 (it should be multiple of 500) so when I press increment, "a=501" should become = 1000 "a=1150" should become = 1500 "a=999" should become = 1500 "a=2400" should become = 2500 so when I press decrement, "a=501" should become = 500 "a=1150"...
  • u

    user

    07/19/2022, 6:41 PM
    Spring WebFlux handler for kotlin SharedFlow I can see the following example working in Spring WebFlux handler for a flow builder like the next one: suspend fun getDummyFlow(req: ServerRequest): ServerResponse { val flow = flow { // flow builder for (i in 1..3) { delay(1000) // pretend we are doing something useful here emit("Hello $i") // emit next value } } return ServerResponse .ok() .contentType(MediaType.TEXT_HTML) .bodyAndAwait(flow) } Yet, I need to...
  • u

    user

    07/19/2022, 6:41 PM
    Kotlin || How to adjust Gridlayout width and height parameters programatically for all screen sizes? I have a gridlayout with fixed height and weight paramaters. When screensize change automatically ıts getting bigger or smaller. Iv tried all methods but not succeed. How to fix? My code ; private fun loadBoard() { for (i in boardCells.indices) { for (j in boardCells.indices) { boardCells[i][j] = ImageView(this) boardCells[i][j]?.layoutParams = GridLayout.LayoutParams().apply { rowSpec = GridLayout.spec(i) columnSpec =...
  • u

    user

    07/19/2022, 7:01 PM
    java.lang.SecurityException: Call from user 0 as user 8333 without permission INTERACT_ACROSS_USERS or INTERACT_ACROSS_USERS_FULL not allowed My app crashes on an android 11 device when I try to show a toast from a fragment by clicking a button in the adapter. I have an interface through which the toast is shown. The error log is: java.lang.SecurityException: Call from user 0 as user 8333 without permission INTERACT_ACROSS_USERS or INTERACT_ACROSS_USERS_FULL not allowed. at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) at android.os.Parcel.createException(Parcel.java:2357) at...
  • u

    user

    07/19/2022, 7:21 PM
    Having problems understanding how getpackagemanager() is derived from getactivity() kotlin I was looking through some docs when I stumbled upon this line of code if (activity?.packageManager?.resolveActivity(intent, 0) != null) { startActivity(intent) } I was puzzled as I can't seem to find packageManager as a method in the activity class, how did the activity instance use the dot operator with packagemanager if it is not one of the Activity class properties? Upon further digging, the packageManager method can be found in the ContextWrapper class, any idea how this works?...
  • u

    user

    07/19/2022, 7:41 PM
    Kotlin Parsing json array with new line separator I'm using OKHttpClient in a Kotlin app to post a file to an API that gets processed. While the process is running the API is sending back messages to keep the connection alive until the result has been completed. So I'm receiving something like {Status(status=,transcript=,error=)} {Status(status=,transcript=,error=)} {Status(status=,transcript=,error=)} {Status(status=,transcript="Hello, World",error=)} Which I believe is being separated by a new line character, not a comma. I figured out...
  • u

    user

    07/19/2022, 7:41 PM
    Is there a simple way to hide the Navigation Bar in Android Studio? In the android studio, you can easily remove the status bar by adding a line in the themes.xml file. true This simple one-line code will hide the status bar. If the user touches the top part of the screen, it appears but after 1 or 2 seconds it disappears again. Is there a similar way to achieve the same effect for the navigation bar? I am using Android Studio Chipmunk 2021.2.1. Here is my build.gradle file // Top-level build file where you can add configuration options common to all...
Powered by Linen
Title
u

user

07/19/2022, 7:41 PM
Is there a simple way to hide the Navigation Bar in Android Studio? In the android studio, you can easily remove the status bar by adding a line in the themes.xml file. true This simple one-line code will hide the status bar. If the user touches the top part of the screen, it appears but after 1 or 2 seconds it disappears again. Is there a similar way to achieve the same effect for the navigation bar? I am using Android Studio Chipmunk 2021.2.1. Here is my build.gradle file // Top-level build file where you can add configuration options common to all...
View count: 4