https://kotlinlang.org logo
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, 9:01 AM
    how can i fix initialized error in springboot on kotlin? im trying make filter about authorization token in springboot on kotlin, below code is filter @Slf4j class TokenFilter : Filter { private val log = LoggerFactory.getLogger(javaClass) @Throws(IOException::class, ServletException::class) override fun doFilter(servletRequest: ServletRequest?, servletResponse: ServletResponse?, filterChain: FilterChain) { val req = servletRequest as HttpServletRequest val res = servletResponse as HttpServletResponse val...
  • u

    user

    07/19/2022, 9:01 AM
    Can I use Mockito.any() into then method I want to use any() inside then method. Here is my test code: @ExtendWith(MockitoExtension::class) internal class UserSignInProviderTest { @Mock lateinit var authApiClient: AuthApiClient @Mock lateinit var userRepository: UserRepository @InjectMocks lateinit var userSignInProvider: UserSignInProvider @BeforeEach internal fun setUp() { userSignInProvider = UserSignInProvider(userRepository, authApiClient) } ... } There are 3 stubs here....
  • u

    user

    07/19/2022, 9:01 AM
    IllegalStateException androidx.fragment.app.DialogFragment$4 in onChanged I'm facing a weird crash 💥 , I don’t know how can I track this crash. DialogFragment can not be attached to a container view java.lang.IllegalStateException: DialogFragment can not be attached to a container view at androidx.fragment.app.DialogFragment$4.onChanged(DialogFragment.java:151) at androidx.fragment.app.DialogFragment$4.onChanged(DialogFragment.java:144) at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133) at...
  • u

    user

    07/19/2022, 9:21 AM
    How can I make an Augmented Reality SkyView-like UI on Android Studio? I am working on a satellite tracker app for android, and after the orbit propagation I have to display on the screen visible satellites based on device orientation. I want it to look somehow like

    this appâ–ľ

    . I wonder If someone could tell me how can I make this, if there is a graphics library for this type of augmented reality UI.
  • u

    user

    07/19/2022, 9:41 AM
    Convert swift to Kotlin for greatestFiniteMagnitude I was trying to convert this swift code into KOTLIN. unfortunately, I am not familiar with swift code. here I am requesting help to equal code for KOTLIN for the range function. Your help will be appreciated. Thanks in Advance

    https://i.stack.imgur.com/TujR5.jpgâ–ľ

  • u

    user

    07/19/2022, 9:41 AM
    Run main thread process in background using Rx java and show changes? Can anybody give me a suggestion on how we run our main thread process in the background thread and show its updates using RX-JAVA?
  • u

    user

    07/19/2022, 9:41 AM
    How to replace Bundle/Argument deprecated get(key) calls in Android I have the following extension functions that allow me to pass bundle data items between my applications activities and fragments. inline fun Activity.extra(key: String, default: T? = null): Lazy = lazy { val value: Any? = intent?.extras?.get(key) if (value is T) value else default } inline fun Activity.extraNotNull(key: String, default: T? = null): Lazy = lazy { val value: Any? = intent?.extras?.get(key) requireNotNull(if (value is T) value else default) {...
  • u

    user

    07/19/2022, 9:41 AM
    How can I make recyclerview scroll by only one direction and disable others I just want to allow only scroll left in horizontal recyclerview for example. Please help me on that
  • u

    user

    07/19/2022, 9:41 AM
    Flow observe changes of another flow in Kotlin I am making an weather app and want the weather update whenever receive new location. But I always meet crash here. I already log the location retrieve to confirm its lat and lon. private val _currentLocation = MutableStateFlow(MapLocation()) init { viewModelScope.launch { locationRepository.location.collect { _currentLocation.value = it Log.d(TAG, _currentLocation.value.toString()) } } } val...
  • u

    user

    07/19/2022, 10:01 AM
    Exoplayer don't show controller on play/pause I want to implement mediaKeyEvents in my Exoplayer for usage on TVs. For now I have a working setup: override fun onCreate(savedInstanceState: Bundle?) { ... //Don't show controller on start viewBinding.playerView.controllerAutoShow = false ... } override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean { when (keyCode) { KeyEvent.KEYCODE_MEDIA_PLAY -> { if (viewBinding.playerView.player!!.isPlaying) {...
  • u

    user

    07/19/2022, 10:01 AM
    Create list/array of Textviews to change .text via index So I was hoping to make a list/array of textviews so that I can iterate a loop and set the .text value of the TextViews as I go. Otherwise I would have to set the values in the code statically which would be a whole lot messier and potentially not even feasible for my needs. So in the code below the idea would be to iterate the loop and when the correct value is confirmed that [index] would then set the corresponding var refillToken : Double = (0).toDouble() var tweetStored : BooleanArray =...
  • u

    user

    07/19/2022, 10:21 AM
    Jetpack Compose: How to detect when TabRow inside HorizontalPager is visible and call a ViewModel function? I am building a simple app which has a TabLayout with two tabs. One tab is a list of items which you can click and make a note about the item. The other tab is a list of notes you made in the first tab. I have created a TabLayout using TabRows and HorizontalPager here is the code for that section: @OptIn(ExperimentalPagerApi::class) @Composable fun HorizontalPagerTabLayout( modifier: Modifier ) { val tabData = listOf("Records" to Icons.Default.Phone, "Notes" to Icons.Default.Star)...
  • u

    user

    07/19/2022, 10:21 AM
    Call cPanel API's to grant access to a remote MySQL user from Kotlin I want to call cPanel API's to grant access for a remote MySQL user, from Kotlin. It is for a Register User functionality. Basically I want from my Kotlin code to call cPanel API's to: create that user on a remote MySQL database hosted on a VPS set a password for that user grant access to the database from everywhere How can I please do that? I read cPanel documentation but is not very clear, for example I have: <a href="https://api.docs.cpanel.net/openapi/cpanel/operation/Mysql-create_user/"...
  • u

    user

    07/19/2022, 10:21 AM
    Is there any best way to port all eventbus code to coroutine from a lagacy Android project? We have a large lagacy Android project. It's code contains hundreds of greenrobot eventbus source. We need to port them to kotlin coroutine version now. What is the best and high efficiency way to port them to kotlin coroutine version?
  • u

    user

    07/19/2022, 10:21 AM
    Toolbar slides up when calling share intent I have a toolbar at the top of the screen, and when I call share intent the toolbar crawls up, how can I fix that?

    https://i.stack.imgur.com/aFFlE.jpgâ–ľ

    https://i.stack.imgur.com/bQLDk.jpgâ–ľ

    https://i.stack.imgur.com/6Osqs.jpgâ–ľ

  • u

    user

    07/19/2022, 11:01 AM
    In Kotlin, How to groupBy only subsequent items? I want to groupBy a list of items by its value, but only if subsequent, and ignore grouping otherwise: input: val values = listOf("Apple", "Apple", "Grape", "Grape", "Apple", "Cherry", "Cherry", "Grape") output: {"Apple"=2, "Grape"=2, "Apple"=1, "Cherry"=2, "Grape"=1}
  • u

    user

    07/19/2022, 11:21 AM
    How to do string concatenate inside viewmodel observe? So the Categories here is a List which has id and name attribute. I want to concat all of category.name elements in the list before I bind it to view. But the categoryString still "". private fun getData(id: Int){ buyerViewModel.getProductDetail(id).observe(viewLifecycleOwner){ it.data.let { data -> var categoryString = "" data?.Categories?.forEachIndexed { index, category -> if(index == data?.Categories.size - 1){...
  • u

    user

    07/19/2022, 11:21 AM
    Jetpack Compose not updating / recomposing Flow List Values from Room DB when DB Data is getting changed I'm trying to show a List of Items in my Android App. I'm using Jetpack Compose, Flows and RoomDB. When launching the Activity all Items are shown without any problems, the Flow get's items collected and they are displayed. But when I change some properties of the Item in the Database, the changes are not displayed. In my case I change the item to deleted, but it's still displayed as not deleted. When I look at the Database Inspector, the value is changed in the database and set to deleted....
  • u

    user

    07/19/2022, 11:21 AM
    Highlighted marker window cutted at the left corner of Chart MPAndroidChart I'm using custom class for creating MPAndroidChart marker. It's just simple class where i'm using my own XML layout for creating marker. I'm sending 35 entries to my chart and it's not scrollable. The problem is: if we highlight value at the beginning of the chart it's ok and marker window always stick to left corner of the chart. But if highlight latest value then highlighted marker getting cutted because of it's layout laying outside of chart. Why is this doesn't behave same as left...
  • u

    user

    07/19/2022, 11:41 AM
    ClassNotFoundException rises from Custom Android Version (i.e., AOSP) when using DexClassLoader I want to call my kotlin library inside Android using DexClassLoader after converting my library & its dependencies jar files to dex files using d8 tool. The d8 tool is able to compile the library without any warnings but the dexClassLoader can't find kotlin.jvm.internal.Intrinsics class which I made sure it's there when I opened the dex files in Android Studio. Can someone help me?
  • u

    user

    07/19/2022, 11:41 AM
    CustomMaterialDataPicker to select just one day I was developing an App where I need to implement the following component of android library: RangeDateSelector. My main goal is limit the selection to just one day, instead of allow pick a range of days. To do this I use my CustomDataPicker, which allow to select a range of dates: CustomMaterialDatePicker @SuppressLint("RestrictedApi") class CustomMaterialDatePicker : RangeDateSelector() { private var first = true private var firstDate: Long? = null override fun...
  • u

    user

    07/19/2022, 12:01 PM
    None of the following functions can be called with the arguments supplied on koin in jetpack compose I am using koin v3.2.0 in my jetpack compose application. I am getting weird issue on my viewModelOf. I imported correctly as well from the sample project. dependencies { implementation 'androidx.core:core-ktx:1.8.0' implementation "androidx.compose.material:material:$compose_version" implementation...
  • u

    user

    07/19/2022, 12:21 PM
    Custom Spring Data JPA @Query not working for Postgres JsonB I have a Postgres table with a json blob column - CREATE TABLE mytable ( id serial primary key, data jsonb ); With a couple of records - INSERT INTO mytable (id, data) VALUES (1,'{"num": "123", "status": "DRAFT"}'); INSERT INTO mytable (id, data) VALUES (2,'{"num": "456", "status": "LIVE"}'); I'm able to select using the json keys 'num' and 'status' like this - SELECT * FROM mytable WHERE data @> '{"num": "123", "status": "DRAFT"}'; I am trying to put this into a custom query with...
  • u

    user

    07/19/2022, 12:21 PM
    How to Store an YEAR from DatePickerDialog in Kotlin? So basically i want to get the year from the user using the datePickerDialog and then substract that year to the current year. Till this i have no issues. The problem is i have button created and want users to get a Toast message if they haven't chosen the date. I am using if else and validating the Year when the datePicker is not selected. Also the year i am getting after the datePickerDialog is the current year. Here is the Code - fun birthdayPicker() { val cal =...
  • u

    user

    07/19/2022, 12:21 PM
    How can I keep a countdown timer running even if I don't open the app for a long time? I've been making a timer app using CountDownTimer, and now I'm testing if it works properly. However, if I set a bit longer period, for example 1h30m, and close the app, it stops working, and when I open the app, it shows the initial screen, the timer I set disappears. I tried to turn off "Battery Optimization" in this app. I tried to turn on "Background Work" in this app. But they didn't work.
  • u

    user

    07/19/2022, 12:21 PM
    Why I can only retrieve current location when already having permission? I want to handle something in my ViewModel whenever the current location retrieved. But it didn't work at the first time I start the app and approve the permission. Only be able to see some logs after I close and start the app again. init { viewModelScope.launch { locationRepository.location.collect { Log.d(TAG, it.toString()) My repository to connect the location data source as you can see class LocationRepositoryImpl @Inject constructor( private val dataSource:...
  • u

    user

    07/19/2022, 12:41 PM
    Lambda without VPC has no internet access My lambda function is not configured into a VPC and has the sufficient role's and permissions to access a particular S3 bucket. However, when running the handler, I get the following error message: error=Unable to execute HTTP request: Connect to context-stage-environment-my-bucket.s3.eu-central-1.amazonaws.com:443 [context-stage-environment-my-bucket.s3.eu-central-1.amazonaws.com/1XX.5X.1X.2XX] failed: connect timed out The section from the handler which causes the issue: val...
  • u

    user

    07/19/2022, 12:41 PM
    Facing issues with retrofit in kotlin. in mvvm and dagger I am trying to parse this json response using retrofit and kotlin in mvvm { "statusCode":200, "status":true, "dataObject":[ { "myHierarchy":[ { "heirarchyList":[ { "contactName":"name1", "contactNumber":"9182928292", "designationName":"desgination1" }, { "contactName":"name1", "contactNumber":"9182928292", "designationName":"desgination1" }, { "contactName":"name1", "contactNumber":"9182928292", "designationName":"desgination1" } ] } ] } ] } This is my ViewModel, I am trying to implement...
  • u

    user

    07/19/2022, 1:01 PM
    AspectJ - Get method parameter value by path? I have an authorizaton Aspect that checks specific conditions based on method annotation. This specific example shows annotation to mark a method that is only accessible by customer service. But unfortunately this isn't the only condition. We have to confirm the customerServiceId that is also passed as one of method parameters. The parameter containing customerServiceId is pretty nested, so I was wondering if it's possible to get parameter value by some kind of a "path". So let's say we have...
  • u

    user

    07/19/2022, 1:01 PM
    App crash after sending message to Firebase Database? so I use Firebase Database for messaging feature and when I send a message, the following error comes out and the app crash. Later on, the chatting activity keep crashing and need to delete the message on Firebase manually to be able to reopen the chatting activity. 2022-07-19 22:56:27.078 21525-21525/com.example.gesit E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.gesit, PID: 21525 com.google.firebase.database.DatabaseException: Can't convert object of type java.lang.String to...
Powered by Linen
Title
u

user

07/19/2022, 1:01 PM
App crash after sending message to Firebase Database? so I use Firebase Database for messaging feature and when I send a message, the following error comes out and the app crash. Later on, the chatting activity keep crashing and need to delete the message on Firebase manually to be able to reopen the chatting activity. 2022-07-19 22:56:27.078 21525-21525/com.example.gesit E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.gesit, PID: 21525 com.google.firebase.database.DatabaseException: Can't convert object of type java.lang.String to...
View count: 6