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

    04/25/2017, 5:39 PM
    runOnUiThread is not calling localChatManager.addIncomingListener { from, message, chat -> Log.v(TAG,"listener") //You can't modify views from non-UI thread. this@chatActivity.runOnUiThread { object :Runnable{ override fun run() { Log.i(TAG,"runOnUiThread") } } } } I am not able to figure out why runOnUiThread is not working but outside of that method everything is working as...
    k
    • 1
    • 2
  • u

    user

    04/18/2019, 1:41 PM
    How to create reusable interceptors in ktor? In ktor, it appears the way to do customized permissions checks is through interceptors, like so: route("/portal") { route("articles") { … } route("admin") { intercept(ApplicationCallPipeline.Features) { … } // verify admin privileges route("article/{id}") { … } // manage article with {id} route("profile/{id}") { … } // manage profile with {id} } } What is the best way to extract the interceptor logic for reuse for other routes elsewhere in the codebase?
    h
    • 1
    • 3
  • u

    user

    06/19/2022, 1:41 PM
    Paragraphs in android string resources not rendering in textview views I tried to create a text with separate paragraphs in a string resource. The Android documentation states that is supported, but it is ignored. I can insert a \n, but that doesnt insert any space between the paragraphs. I use \n\n as a work around, but 2 newlines simply wastes too much vertikal space. Can I post-process the string in kotlin to fix that? Lorem ipsum dolor sit amet,...
  • u

    user

    06/19/2022, 1:41 PM
    How do i get the lyrics of a song if I use a API for Songs? I am Making a Music Streaming App most of it is Done but there is just one problem. I am stuck at the lyrics part I have been trying to find a way if there is lyrics that i can get with the API that I use. By the way I am Using Napster Music API for my app https://developer.napster.com in the API I dont get the song with lyrics. So can i Use other API's for lyrics. I tried to use one named Musixmatch but didnt work. Any...
  • u

    user

    06/19/2022, 2:01 PM
    How to have big title below toolbar by default and when user scrolls title needs to go to toolbar in kotlin I had tried by using collapsing toolbar it is not worked since it had fixed toolbar height.
  • u

    user

    06/19/2022, 3:01 PM
    Rate app multiple times in google play problem? I have an android app that i need to add a rating popup to so i used below code fun showRate() { AppRating.Builder(this) .setMinimumLaunchTimes(5) .setMinimumDays(4) .setMinimumLaunchTimesToShowAgain(5) .setMinimumDaysToShowAgain(10) .setTitleTextId(R.string.RateMessage) .setStoreRatingTitleTextId(R.string.ClickRate) .setStoreRatingMessageTextId(R.string.EmptyMessage) .setRatingThreshold(RatingThreshold.NONE)...
  • u

    user

    06/19/2022, 3:41 PM
    Is there a way to check if user has scrolled before Is there a way in Kotlin and jetpack composes Lazylists to check if the user has scrolled the list before checking if it stopped? I know that there is a state of isScrollInproggress but if you ask if !isScrollinproggress then this will be true from the start before the user has eaven scrolled once. So my question is is there like a scrollended state to get a hold of or am i screwed?
  • u

    user

    06/19/2022, 4:01 PM
    hiltViewModel<ViewModel>() vs by viewModels() (This might not be relevant, but I haven't been able to find the answer anywhere and it's been bugging me) While creating and reviewing applications that use dagger-hilt I noticed that most people, to create an instance of their viewModel class, use something like val viewModel: XViewModel by viewModels() and some use val viewModel = hiltViewModel() is there any difference between those two?
  • u

    user

    06/19/2022, 5:01 PM
    How to observe livedata of nested relation pojo android room The schema of my Database has 4 tables Server, Sites, Groups and Messages. Every Server has many Sites and every Site has many Groups. There is a POJO called GroupItem that holds the Group and the unreadMessages of the Group. data class GroupItem( @Embedded val group: Group, @ColumnInfo(name = "unreadCounter") val unreadCounter: Int ) The unReadCounter field can be found only with a join with the Messages table. I also have a POJO that holds a Site with its GroupItems...
  • u

    user

    06/19/2022, 5:01 PM
    How to remember preference change throughout app I'm looking to ensure my app always remembers a preference whenever a change by the user occurs. when this particular preference option Switch is OFF: ...

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

    ... I want this change to be remembered throughout my time using the app (including when I navigate to a different screen), and to hide the image views (located in a completely different screen): ... <a href="

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

    " rel="nofollow...
  • u

    user

    06/19/2022, 5:21 PM
    How to correctly inflate menus for an action bar from viewpager fragments I have my viewpager as follows: val pagerAdapter = ViewPagerAdapter() viewPager2.apply { offscreenPageLimit = 2; adapter = pagerAdapter } override fun createFragment(position: Int): Fragment = list[position].fragment So all fragments are inflated from the start. But I don't know how or where to inflate the menu for my action bar from each fragment. Because if I inflate it like this: override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?,...
  • u

    user

    06/19/2022, 5:21 PM
    Kotlin Not able to recognise Deferred/Promise/Future values in a map which has Values as String or Deferred Value val varToValue = mapOf("@id" to arg.userId, "@salary" to arg.salary) for (variable in varToValue.keys) { fieldData = fieldData.replace(Regex(variable),if(varToValue[variable] is String) varToValue[variable] else varToValue[variable]?.await() ?: "") //here } Here fieldData is a string which might contain @id or @salary. arg.id is of type String and arg.salary is of type Deferred. Now the line where I call the replace function is not able to identify...
  • u

    user

    06/19/2022, 5:41 PM
    How to create application scooped pool of jobs to avoid duplication of network API call in android How to create application scooped pool of jobs to avoid duplication of network API call in android. Lets assume my NetworkManaget has methods called getData(uniqueId: String): List and let's say multiple screen is calling getData(uniqueId) method from the same requests at the same time. Here requirement is, NetworkManaget should not make duplicate API call however it should serve the results to all screens.
  • u

    user

    06/19/2022, 5:41 PM
    Android Studio: Adding Kotling to existing Java app ends up in "Internal error: unexpected lint return value -1" when building I'm adding Kotlin to my existing Java app (I first have to say I've already done it to another of my apps with no problems at all) and after following all required initial steps I always get an "Internal error: unexpected lint return value -1" with no error details when building. This is the relevant part of my project's grade file: buildscript { ext.kotlin_version = '1.7.0' repositories { jcenter() mavenCentral() google() } dependencies {...
  • u

    user

    06/19/2022, 5:41 PM
    How add a image switcher in a kotlin app? Hello everyone I'm a young developer and I'm making an app where I want to use a image switcher but I've looked on internet and everything I've tried make the activity crash. I'm using kotlin Anyone can help me please?
  • u

    user

    06/19/2022, 5:41 PM
    App keeps crashing and Logcat states "lateinit property todoAdapter has not been initialized" This is the Main activity for a simple todo list app if you want to see more of the code then please let me know When private lateinit var todoAdapter: TodoAdapter is removed app no longer crashes but the app will no longer show the todo item on the recycler view "package com.example.todoit import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.text.TextUtils import android.widget.Toast import androidx.recyclerview.widget.LinearLayoutManager import...
  • u

    user

    06/19/2022, 6:01 PM
    why when restarting the app, onboarding screen shows again in android jetpack compose? I have onboarding screens in my android jetpack compose project, and when I close and restart the app again, I see onboarding screen again, I try to use some of code from this example, but it is throw error for getOnboardState(), showSpinner(), navigateToOnboarding(), showContent(), as a Unresolved reference I do not know what I missed in my code, any idea? @AndroidEntryPoint class MainActivity : ComponentActivity() { enum...
  • u

    user

    06/19/2022, 6:01 PM
    how to save an object in object in real-time database, Firebase (kotlin) I would like to save data into the real-time database of Firebase, but I run into a problem. I've only been working with Kotlin for 1 month, and unfortunately I don't know how to save data to the real-time database in this form, as shown in the picture. My current code is this: data class userData( val username: String, val uid: String, ) database = FirebaseDatabase.getInstance().getReference("Userdata") val user = uid?.let { userData("Test1", it) } if (uid != null) {...
  • u

    user

    06/19/2022, 6:21 PM
    How do I implement that a fragment doesn't get saved onto the backstack? I work on an app and this app has a list fragment as the starting point when you open the app. Now when I click on a listItem an update fragment opens and when you press the save button you go back to the list fragment. The problem is that when I now press the back button on my phone in order to exit the app that doesn't happen and instead I go back to the update fragment. I would like to make it so that the update fragment doesn't get saved onto the backstack or at least I think that might...
  • u

    user

    06/19/2022, 7:21 PM
    Android Kotlin: Not being able to use registerforactivityresult After migrating this next Java class: public class ImportExportActivity extends BaseActivity { private String filename; private static Intent oData; private ActivityResultLauncher activityResultLauncher; private ActivityImportexportBinding binding; @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setImportDataActivityResultHandler(); } @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)...
  • u

    user

    06/19/2022, 7:41 PM
    Color of GradientDrawable not visible in SwipeToEditCallback in android I am using the swipe to edit/delete feature for the recycler view and want the drawable to be curved so for the SwipeToDeleteCallback.kt I used GradientDrawable() as it allows rounded corners package com.example.happyplaces.utils import android.content.Context import android.graphics.Canvas import android.graphics.Color import android.graphics.Paint import android.graphics.PorterDuff import android.graphics.PorterDuffXfermode import android.graphics.drawable.ColorDrawable import...
  • u

    user

    06/19/2022, 8:01 PM
    how can I solve this error (Unresolved reference mariuszgromada) [duplicate] // this is the main activity.kt the error is (Unresolved reference mariuszgromada) how can I solve it please help!! How do I fix this Unresolved reference mariuszgromada error, I write this code 2 times and the same error is exits and thanks for your effert anybody explain please! anybody help please! I don't know why the error is exits package com.example.calculator import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import androidx.core.content.ContextCompat...
  • u

    user

    06/19/2022, 8:01 PM
    How to move an existing Line shape in java using a mouse? I would like to drag a selected line, but I'm unsure how to do it. I tried the following but it doesn't work and the line doesn't move correctly. What calculations am I missing? var deltaX = mouseEvent.x - (line.startX + line.endX) var deltaY = mouseEvent.y - (line.startY + line.endY) line.startX = line.startX + deltaX line.startY = line.startY +deltaY line.endX = line.endX + deltaX line.endY = line.endX +deltaY
  • u

    user

    06/19/2022, 8:41 PM
    Errors during flutter app build. "Kotlin: Unresolved reference: embedding" and "Kotlin: Unresolved reference: FlutterActivity" As in title I'm getting errors during flutter app build. I already tried this solution And when I'm syncing all dependencies and all stuff in android folder I'm getting error: "Could not create task ':generateLockfiles'." I tried multiple solutions from forum and sometimes they help(sometimes because it's temporary to point when I'm creating new project with...
  • u

    user

    06/19/2022, 9:21 PM
    How do I implement PostGIS database to my android app in kotlin? I am trying to create an app in kotlin to draw lines and polygons on google map and save it to PostGIS database. I am still wondering how that could be done. Suggestions would be highly appreciated. Thanks
  • u

    user

    06/19/2022, 9:21 PM
    How to make the soft keyboard hide when clicked outside of the focused EditText BUT not if another EditText is clicked? I want the focused EditText to lose its focus and the soft keyboard to hide when clicked outside the EditText box BUT only when another EditText is not clicked, so these are the scenarios: The EditText is focused, another EditText is clicked - lose first EditText's focus BUT don't hide the soft keyboard as another EditText's focus is requested. The EditText is focused, some other part of the Layout is clicked - lose EditText's focus AND hide the soft keyboard as none of the EditTexts is...
  • u

    user

    06/19/2022, 10:01 PM
    Spring Data Reset - how to create an object with relationships in one request? @Entity @Table(name = "distributor") class Distributor : AbstractEntity() { @Column(nullable = false) val name: String? = null @OneToMany(mappedBy = "distributor", cascade = [CascadeType.ALL]) @RestResource var managers: MutableList? = null @OneToMany(mappedBy = "distributor") var catalog: MutableList = mutableListOf() } @Entity @Table(name = "distribution_manager") class DistributionManager : AbstractPersonEntity() { @ManyToOne @JoinColumn(name =...
  • u

    user

    06/19/2022, 10:21 PM
    Callback function not called in second times I have use Couchbase for my database. Short story is, i created callback function when replication has been success that callback will be called. After trigger it, activity that listen this callback will be got return value. Fyi, couchbase have push & pull replication data that activate by calling their listener function. In my case i only use pull replication listener. This listener will be stopped when they had listen all data from db. And this when it is stop, will be trigger my callback...
  • u

    user

    06/19/2022, 11:01 PM
    What is the meaning of following function parameter signature onChanged: ((Int?) -&gt; Unit)? = null? I have a function with several parameters. One of these paramters is private fun mySpecialFunction( variable1: Int, onChanged: ((Int?) -> Unit)? = null ) Later in the function it is invoked like: onChanged?.invoke(2) And on the upper calling site, it is called like: mySpecialFunction( variable1 = 1, onChanged = { // do something with the number invoked above } ) How is this usage of onChange called in Kotlin?
  • u

    user

    06/19/2022, 11:21 PM
    Android Volley Posting twice using kotin to php server i am posting image with additional data to a php script but its been posted twice by the API volley am unable to resolve please help. basically the image gets posted twice as well as the data gets saved twice to mysql db i am unsure why its upload or retrying twice because the connection is fine. also wanted to ask if their ways a way to add a progress bar to my code so that its show how long. i would really appreciate the posting twice error help thanks. val url =...
Powered by Linen
Title
u

user

06/19/2022, 11:21 PM
Android Volley Posting twice using kotin to php server i am posting image with additional data to a php script but its been posted twice by the API volley am unable to resolve please help. basically the image gets posted twice as well as the data gets saved twice to mysql db i am unsure why its upload or retrying twice because the connection is fine. also wanted to ask if their ways a way to add a progress bar to my code so that its show how long. i would really appreciate the posting twice error help thanks. val url =...
View count: 2