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/11/2022, 12:31 AM
    Percent unit from CSS to Kotlin React? I was trying to use the percent unit (%) from CSS to my Kotlin React file, it has the others unit but I cant find this one. I was looking in Length.kt. If there's not that unit, how could I do the same? I'm trying to make an input with 50% height compared to its parent. I'm new in Kotlin. Please help!
  • u

    user

    07/11/2022, 1:11 AM
    Android Kotlin LazyThreadSafetyMode.NONE In most of the samples regarding Android View Model and lazy init nobody refers to the parameters which can be used in by Lazy. From the Kotlin docu: If you're sure that the initialization will always happen in the same thread as the one where you use the property, you can use LazyThreadSafetyMode.NONE. It doesn't incur any thread-safety guarantees and related overhead. I can not...
  • u

    user

    07/11/2022, 1:51 AM
    snapshot.getValue(ChatMessage::class.java)) is returning null Getting a null value when running: snapshot.getValue(ChatMessage::class.java)

    https://i.stack.imgur.com/BUzE8.pngâ–¾

    ChatLog.kt class chat_log : AppCompatActivity() { val adapter = GroupAdapter() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_chat_log) val user = intent.getParcelableExtra("user") val actionBar = getSupportActionBar()...
  • u

    user

    07/11/2022, 2:11 AM
    How to add images to DB Browser for sqlite that are stored in drawable folder? I am trying to pre-populate a room database with some data using DB Browser for sqlite. I have a table defined with (name: String, score:Int, image:Int). That image field stores an image from drawable folder so the example for an insert would be : INSERT INTO player (name,score,image) VALUES ("Mike", 31, R.drawable.mike) Since the table field is Int, DB Browser wont let me store R.drawable.mike which is the image location in android studio as it expects a number. Error : Execution finished...
  • u

    user

    07/11/2022, 2:11 AM
    Why I get null when I try to access view by ID? I have a function, cauntMe() that is triggered when the button is clicked. fun cauntMe(view: View){ val textView = view.findViewById(R.id.textView) val countString = textView.text.toString() var count: Int = Integer.parseInt(countString) count++ textView.text = count.toString() } Here is XML declaration of the view: In triggered function this row return null: view.findViewById(R.id.textView) Here is class: class MainActivity : AppCompatActivity() { override fun...
  • u

    user

    07/11/2022, 2:31 AM
    When should one use Modifier.then? What is the purpose or when is it useful to use Modifier.then in jetpack compose?
  • u

    user

    07/11/2022, 3:11 AM
    Android Kotlin AlertDialog.Builder() usage and context. "this" not working This is my very first time using Kotlin/Android App Development, so I apologise if I am missing something simple. I have a background in Java and C#. I'm trying to display an AlertBox containing X information. All the tutorials I am reading/watching stay that the constructor should be: val builder = AlertDialog.Builder(this) This issue I am having trouble with is the "this" part. I get a Type Mismatch error for the "this" reference. I have tried searching for a solution and I find variations...
  • u

    user

    07/11/2022, 4:31 AM
    What is this pop up by Samsungs clock? pardon my lack of knowledge. Can anyone tell me what this popup from Samsungs clock is when an alarm goes off? Is it a fragment, or an activity of its own? I was reading and android.com says that starting activities when the user is on screen is restricted. It can't be done because it is obtrusive. Could you please tell me what this pop up is called, and is it an activity, fragment, something else?

    https://i.stack.imgur.com/dHbcm.jpgâ–¾

  • u

    user

    07/11/2022, 4:31 AM
    How to get API response in kotlin wanted to get items inside "item_optional" but cant seems to figure out how to make the model class in Realm.

    https://i.stack.imgur.com/pkEoq.pngâ–¾

  • u

    user

    07/11/2022, 4:31 AM
    How can I send Notification when New data added in Json file or in API ? in Android Kotlin / Java I have an application which need to notify user when there is new data added in API. How programmatically it will do ? Note: I checked all the reference but still getting not solution that I want.
  • u

    user

    07/11/2022, 5:51 AM
    How to convert custom callback to coroutine I am using Stripe library which provides me with custom callback functionality. I want a custom callback convert to Kotlin coroutine Here is the code override fun retrievePaymentIntent(clientSecret: String): Flow = flow{ emit(Resource.Loading()) Terminal.getInstance().retrievePaymentIntent(clientSecret, object : PaymentIntentCallback { override fun onFailure(e: TerminalException) {} override fun onSuccess(paymentIntent:...
  • u

    user

    07/11/2022, 6:11 AM
    Concurrency in kotlin also block after synchronized block I have a block of code like this in kotlin. synchronized(this) { // do some work and produces a String }.also { /*it: String*/ logger.log(it) } can some thread come and with unlucky timing the it variable gets changed before logging happens? (There are a lot of threads executing this piece of code concurrently)
  • u

    user

    07/11/2022, 6:31 AM
    Google Map Clustering I have implemented google map clustering in my app. Since all the locations are very close to each other, the clustering is shown even when zoomed in. I need the map to show the default markers upon zooming in. How can I do this?
  • u

    user

    07/11/2022, 6:31 AM
    How to fix " app:mergeDebugJavaResource " Error I am new to coding Android I tried to start AVD but many of the errors are showing in front of me

    Like thisâ–¾

    could someone else help me to fix it. Thank you.
  • u

    user

    07/11/2022, 7:11 AM
    Displaying the value of the EditText in the TextView at the Simultaneous(online) in kotlin I want the text written inside the EditText to be displayed simultaneously in the TextView without pressing the button (kotlin) thank you
  • u

    user

    07/11/2022, 7:51 AM
    How to create an intent for email only with a file attachment Here's what I want to achieve - I should only be able to see email client apps like gmail and outlook in the options segment. Don't want the rest of the apps. intent.addCategory(Intent.CATEGORY_APP_EMAIL) the code above was one of the suggestions that I saw while searching for how to achieve this. But, here's the issue when I use it...

    https://i.stack.imgur.com/gBAXN.jpgâ–¾

    Also, val emailIntent = Intent(Intent.ACTION_SENDTO) was another suggestion. Has...
  • u

    user

    07/11/2022, 7:51 AM
    channel iterator partially covered [1 of 2 branches] kotlin I have written a custom SQS consumer wherein : One coroutine that periodically retrieves the messages Multiple workers that process the receiving messages in parallel without blocking. A channel to communicate between the MsgReceiver coroutine and the Workers. However, when writing unit tests I am unable to achieve 100% test coverage kover or with sonar. The kover/sonar plugin complains about partially covered while loop [highlighted in yellow] and I cannot understand which scenario have I...
  • u

    user

    07/11/2022, 7:51 AM
    focusOutFront() not working on VerticalGridSupportFragment but working on RowSupportFragment I am working on Android TV using Leanback. Here, I have a list of channel data and their EPG. I have populated the channels list on the VerticalGridSupportFragment. And I also have a date filter button to filter the EPG list as per date. Here, is the design of the channel list and EPG with the filter button.

    https://i.stack.imgur.com/9Me9u.pngâ–¾

    Now, the problem is I can navigate from the filter button to the channel list. But I cannot navigate from the...
  • u

    user

    07/11/2022, 7:51 AM
    Android recyclerview: How to implement asynchronous listeners? I have this code: @Override public void onBindViewHolder(@NonNull final ViewHolder holder, final int position) { ... String username = ...; addListenerForTyping(() -> holder.myTextView.setText(username + " is typing...")); ... } This doesn't work well. There are many items in my list, and when I scroll through them all, while a user is typing, the typing-text will be shown for the wrong item. Not for the item that actually belongs to the typing user. I guess the reason is...
  • u

    user

    07/11/2022, 8:11 AM
    How to display dialog on any screen (fragment or activity) in android User is in Fragment/Activity "A" In the onCreate() of screen "A" i fire some network call on a background thread. User navigates to some other Fragment/Activity, now when i get the response from the network i need to show the dialog no matter wherever the user is in the app. How can i achieve this behavior? using DialogFragment
  • u

    user

    07/11/2022, 8:31 AM
    How to group and then sort the list of objects in Kotlin? I have a list of objects with the following values data class Account(val accountName:String,val deleteAllowed:Boolean,val accountType:String) I want to first display the object with 'deleteAllowed'=false. If there are 2 object with 'deleteAllowed' = false, then the first one to be displayed is the one with 'accountType'="transactional" . And the rest should be sorted based on 'accountName'. For eg, [{accountName="AAA",deleteAllowed=true,accountType="savings"},...
  • u

    user

    07/11/2022, 8:31 AM
    NullPointerException when creating a infinite carousel in Compose I am trying to create a infinite scrollable carousel of cards using this solution @Composable fun CircularList( items: List, modifier: Modifier = Modifier, isEndless: Boolean = false, onItemClick: (String) -> Unit ) { val listState = rememberLazyListState( if (isEndless) Int.MAX_VALUE / 2 else 0 ) LazyColumn( state = listState, modifier = modifier ) { items(...
  • u

    user

    07/11/2022, 9:11 AM
    Not able to access elements with kotlin in android studio I am new to android studio and wanted to make a pretty basic app. The problem is after creating an xml file and giving it id as btnApply, i tried to print something when it gets clicked. I think the code is correct as I have been following a youtube tutorial, but something else like my settings is not allowing me to access the xml file elements. Any fixes?? package com.example.applicationone import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.util.Log...
  • u

    user

    07/11/2022, 9:11 AM
    Kotlin: Generic types in Kotlin To get the class definition to be used for example for json deserialization the following can be used in Kotlin: Map::class.java A example usage is the following: val map = mapper.readValue(json, Map::class.java) But now how to have the generic type definition? Something like this does not compile: val map = mapper.readValue(decodedString, Map::class.java) So my question is: What is the generic equivalent to *::class.java
  • u

    user

    07/11/2022, 9:31 AM
    Draw user's path/route in real-time using Mapbox v10, Android, and Kotlin Using a Mapbox MapView (v10.6.0) and Android, I would like to draw a path in real-time. I do not need Turn-by-Turn Navigation features, but only to track the user's actual route. The approach I am planning to use (unless an easier/better solution comes up) is using a listener as described in the documentation (Display the user's location) that updates the camera every time the user moves,...
  • u

    user

    07/11/2022, 9:31 AM
    Filter a list of transactions I have lists of transactions, I would like if the list contains 4 transactions, delete the two lowest, if the list contains 5 transactions, always the 2 cheapest, if there are 6, the 3 cheapest and so on. allDrivers.map { driver -> val transacsByDriver = allTransacs.filter { transaction -> transaction.driver?.userId == driver.userId } val tt = transacsByDriver.filterIndexed { index, transaction -> Math.floorDiv(index, 2) == index.floorDiv(2)} println(tt)...
  • u

    user

    07/11/2022, 9:51 AM
    Spring read list property dynamically With spring it easily possible to read a normal property using env.getProperty(key) For example if your application.yaml looks like this: test: "a" You can read the value like this: val test = env.getProperty("test") But now assume you want to read the following application.yaml: test: - a: "a" - b: "b" How can I read test[a] dynamically? What does not work unfortunately is this: val test = env.getProperty("test[a]")
  • u

    user

    07/11/2022, 9:51 AM
    Why Daaps, Web3 and Metamsk not open in Webview android studio I am unable to open metamask in webview from uniswap url https://app.uniswap.org/#/swap?chain=rinkeby . Also not lunch Daaps and Web3 website
  • u

    user

    07/11/2022, 9:51 AM
    Can i implements a kotlin/java interface in react native javascript? I'm trying to implement a reactNative library whose native module has a method (annotated with @ReactMethod) that requires an object of type T. That T is an interface written in native language (kotlin). Can i implement that interface in reactNative javascript? And if not, how do i achieve passing an object that implements that interface?
  • u

    user

    07/11/2022, 10:31 AM
    Make last Item of the Compose LazyColumn fill rest of the screen There is a regular list with some data and LazyColumn for showing it. LazyColumn { items (list) { item -> ListItem(item) } } Simplified ListItem looks like: @Composable fun ListItem(item: SomeItem) { Row( modifier = Modifier.fillMaxWidth().height(IntrinsicSize.Min) ) { //Some widgets } } I need to set the footer's item (last in list) height to fill screen if there is not enough items for that. It's easy to find last item and provide some flag to...
Powered by Linen
Title
u

user

07/11/2022, 10:31 AM
Make last Item of the Compose LazyColumn fill rest of the screen There is a regular list with some data and LazyColumn for showing it. LazyColumn { items (list) { item -> ListItem(item) } } Simplified ListItem looks like: @Composable fun ListItem(item: SomeItem) { Row( modifier = Modifier.fillMaxWidth().height(IntrinsicSize.Min) ) { //Some widgets } } I need to set the footer's item (last in list) height to fill screen if there is not enough items for that. It's easy to find last item and provide some flag to...
View count: 3