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/12/2022, 10:31 PM
    How can I see the json generated from Ktor? I want to see the json result of the body but I have no idea how, I am recieving a 400 bad request and I am pretty sure the issue comes from "listOf(PostInvoiceResultInsideLineItems("API", 1, furiousInvoice.amount_inc_tax, "1", "FR_200"))" In the API, it needs something like this: "line_items": [ { "label": "API", "quantity": 1, "currency_amount": 2000, "unit": "1", "vat_rate":...
  • u

    user

    07/13/2022, 1:11 AM
    Spring boot: How to convert a 2 dimensional array of dynamic JavaScript Objects into Kotlin I am trying to send this JSON object to a Spring boot application in Kotlin. It is a 2 dimensional array of objects that each contain a key that is a string and a value that is an integer like so: [ [ { "-1": 272 }, { "2": 0 }, { "apple": -1 }, { "apple": -1 }...
  • u

    user

    07/13/2022, 1:11 AM
    How do I wait for a void function to finish executing before triggering a completable in Android? I'm very new to RxJava/RxAndroid and I'm very confused with how to achieve this workflow: Trigger void function Once it completes, provide some sort of callback to start a Completable function. I tried wrapping my void function in an Observable that emits a , but honestly I've no clue if that's the right thing to do. fun observableFoo(): Observable { return Observable.create { emitter -> emitter.onNext( voidFunction() ) } .subscribeOn(Schedulers.io())...
  • u

    user

    07/13/2022, 1:31 AM
    Android with Kotlin: How to filter DatabaseReference I want to filter a getReference according to the data that is saved in a field. I want it to return only the uid that have the "status" with a value of "1" my code is this for now, it is returning all the uid that are inside "empleados"

    enter image description here▾

  • u

    user

    07/13/2022, 2:11 AM
    Getting a Value from the inside of a Coroutine outside of the Coroutine in Kotlin? I'm pretty new with kotlin programming and have to complete a tourguide project. I have a hopefully simple problem, but I'm too stupid to fix it I guess. In the following code segment I want to use the val "loc" (that's coming from the inside of a coroutine / addOnSuccessListener) as the "startlocation" that is currently set on "LatLng(49.7913, 9.9534)" outside the coroutine. But how do I get that value outside to the main thread? Sadly I can't just do "val startlocation = loc" :( Please,...
  • u

    user

    07/13/2022, 2:31 AM
    How to show the output after user input editText? I want to show output when user input something in the edit text. This is the code snippet submit.setOnClickListener { Toast.makeText(requireActivity(), "$username", Toast.LENGTH_LONG).show() } When I run it, it will appear as this image

    screenshot▾

    But when I change the "text:" into username and declaring var username = binding.text I will get this error None of the following functions can be...
  • u

    user

    07/13/2022, 3:11 AM
    Get Frame Rate of Android using Kotlin I am able to get the frame rate of the Android system using the following answer in Java: https://stackoverflow.com/a/8908035/4190159 However, being new to Kotlin I was wondering how can I get the frame rate of Android system using Kotlin code? (my app is using Kotlin instead of Java) The code as follows is not working for me: fun getFrameRate(): String { val timeElapsed1: android.os.SystemClock =...
  • u

    user

    07/13/2022, 4:11 AM
    Kotlin Singleton Class vs Normal Class I am new in kotlin and i read lots of documentation about singleton pattern and kotlin object declaration. I have some problems about singletons. Firstly, If singletons are beneficial for device memmory, Why is it used so little? How can we decide, we need to use singleton or not ? Why we need multiple instances exactly if singleton beneficial for memmory? If we don't need constructor can we use object all the times instead of class ? And lastly i have a class which is authenticating phone...
  • u

    user

    07/13/2022, 4:31 AM
    How to parse from map to object for Realm pls help me on this. i need to get the response from multiple item options however key is dynamic. I used Map but how can i convert it to object so that realm will accept it like this
    var item_options: @WriteWith RealmList? = null,
    this is my code val multiple_item_options: Map this is the response from api "multiple_item_options": { "151668": [ { "option_name": "Dipping Sauce",...
  • u

    user

    07/13/2022, 4:31 AM
    How to use lifecycle, livedata, and viewmodel with kotlin extensions deprecated This is my first time to learn & use kotlin programming to create an app, so I don't really know much about kotlin. I learn to use it from Indonesian app, called Skill Academy, but the subject regarding it uses kotlin extensions, which is now deprecated. I need your help and shares how to use lifecycle, livedata, and viewmodel using new viewbinding. Thank you
  • u

    user

    07/13/2022, 5:31 AM
    Comapring data class in Kotlin using == operator I am trying to write an assertion by comparing two Kotlin data classes.I am just simplifying the question by using a minimal class. data class X(val isThatSo: Boolean) { val name:String = "xyz" } In my test val s = """ { "isThatSo": "true", "name": "Ankit" } """ assert(Gson().fromJson(s, X::class.java) == X(true)) Looks to me that the name field is not compared at all because the value in both the objects is different. Is my understanding correct?
  • u

    user

    07/13/2022, 5:51 AM
    How to use `apply` in Kotlin when property and function have the same variable name data class Foo( val aaa: String, val bbb: String ) fun bar(aaa: String) { Foo().apply { aaa = aaa // this line gives error bbb = "bbb" } } IDE gives an error Val cannot be reassigned which suggests it's trying to reassign the function level aaa. how can I correctly use apply here to assign value of function level variable aaa to Foo's property aaa?
  • u

    user

    07/13/2022, 5:51 AM
    I had this problem to connect me to the main activity: Modifier 'override' is not applicable to 'local function' I have this problem to connect the menu to the main activity: Modifier 'override' is not applicable to 'local function' This is the main activity code: enter code heclass MainActivity : AppCompatActivity() { private lateinit var adapter: Adapter private lateinit var layoutManger:LinearLayoutManager override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) layoutManger = LinearLayoutManager(this,...
  • u

    user

    07/13/2022, 5:51 AM
    Best way to securely cache data in a kotlin app? New-ish to Kotlin and building an app. I need some objects to be persistent data. Each of these objects will have a unique key. The objects will not take up a ton of memory and the cache size will probably rarely be over 10 of these objects, and most of the time just be 2 or 3 of these objects. I am wondering what is the best way to cache this data? I will encrypt the data but it must also be secure and only accessible by my app, i.e. not accessible by other apps on the phone or backed up by...
  • u

    user

    07/13/2022, 7:11 AM
    How to implement a validation code component I have to implement a validation code component where the user has to introduce a 4 digit code in 4 diferent edit text but I don't know how to start. Never have I seen an example of this and on the internet I can't find any example. This is what i want to implmenent:

    https://i.stack.imgur.com/5dnVv.png▾

    Any help would be a appreciated.
  • u

    user

    07/13/2022, 7:31 AM
    In GlanceAppWidget actionStartActivity is not calling in actionRunCallback inside onRun override function Component used: GlanceAppWidget Library & Version used: androidx.glance:glance-appwidget:1.0.0-alpha03 In the onClick of Button, we use actionRunCallback, inside the onRun override function we are trying to call actionStartActivity but it's not calling this actionStartActivity function. Issue Tracker : https://issuetracker.google.com/issues/238814668 <a href="

    https://i.stack.imgur.com/7MTGU.png▾

    "...
  • u

    user

    07/13/2022, 7:51 AM
    how can i retrieve the coordinates by searching the address name in the osmdroid map app I would like to add to my application an editText box to search for a point using the address, I would like to obtain the coordinates and then trace a path. how can i implement this? is there a tutorial to follow? subsequently I would like to be able to create a route starting from a predetermined starting point and setting a maximum distance that the route must have, can you help me?
  • u

    user

    07/13/2022, 8:31 AM
    How to set (programatically) Gone Margin in Constraint Layout? There is a use case where 4 views are connected vertically (named A,B,C,D respectively from top to bottom). When C is not visible then gone margin is set to 12dp resulting in a height of 16dp(12dp + 4dp RV item margin) from B. But when both B & C are gone then the gap between A & D is needed to be 24dp. The approach I'm using right now is programatically attaching D to the bottom of A & making margin as 24dp. Is there a way by which I...
  • u

    user

    07/13/2022, 8:31 AM
    how to fill the data class from xml file? Early data lay in the application.yml file, but it was necessary to move it into a separate file to solve a parallel problem. The question is how to specify the path to this data. I tried to change the path using PropertySource, but nothing really happened. Each time or data was taken from the same file or spring fell before it could start @ConstructorBinding @ConfigurationProperties(prefix = "merchant-connection") data class ConnectionsProfileProperties( val connectionProfiles: Map ) {...
  • u

    user

    07/13/2022, 9:11 AM
    Unable to start activity ComponentInfo to create tabMenu I´m trying to launch other activity in my app when i´m doing login in my app. This second activity have a tabMenu with a viewPager2 but when my app tray load this activity launch error: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.citysportgym/com.example.citysportgym.ProfileActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.viewpager2.widget.ViewPager2.setAdapter(androidx.recyclerview.widget.RecyclerView$Adapter)' on a...
  • u

    user

    07/13/2022, 9:11 AM
    Kotlin: setTheme not changing the theme colors How to change the theme by programmatically? Style true @android:color/transparent Manifest Activity class PetTransparentActivity : PetBaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { if (missionArgs.isTransparent) { Log.d("Activity", "Transparent") setTheme(R.style.Pet_Theme_Transparent) } else { Log.d("Activity", "Not Transparent") setTheme(R.style.AppTheme_NoBar)...
  • u

    user

    07/13/2022, 9:31 AM
    Add Constraints to ConstraintLayout - Android Studio I've been trying to use constraints with a ConstraintLayout with an ID of card_details to position it on the screen, but the constraints are not working, and the IDE is not recommending them as available attributes as well. Here's the code I'm using. Here's how they look like:

    How the constraints look▾

    The highlighted item should be placed beneath the image with these...
  • u

    user

    07/13/2022, 10:11 AM
    Kotlin Flows/Channel Concurrency Processing Since coroutine flows are sequential performing long running operations in the collector/consumer will cause the execution time to be the sum of the long running operations. To overcome this behavior and execute the long running operation concurrently in the collector/consumer I was wondering if the following code is conformed with coroutines and structured concurrency and also bug free, since it help me achieve the required behavior: private suspend fun listenForResponses( channel:...
  • u

    user

    07/13/2022, 10:11 AM
    Error installing Kotlin plugin in eclipse. Can anyone help me out please?

    This is the screenshot of the error▾

    I have 2 more plugins, PyDev and jar files.
  • u

    user

    07/13/2022, 10:31 AM
    How to create the model from a dynamic api and pass it to Realmlist in kotlin need help. i have a dynmic API key as shown in pic. based on some solutions, i need to use map to handle dynamic. my issue is how to create the model for Realmlist as it is complaining on Map. pls help. already created model for single item: open class SingleMultipleOptions ( var key :String ?= null, var option_name:String?= null, var id:Long?= null, var item_price:Double?= null , var item_name:String?= null ) and this is for Map @SerializedName("multiple_item_options")...
  • u

    user

    07/13/2022, 10:51 AM
    Getting SHA256 digest of an APK programmatically android I have an installed APK on my device, and I am trying to get the SHA256 digest of the same. Manually, I do it like this: apksigner verify --print-certs path/to/apk.apk and use the SHA256 digest. But I need to do the same thing programmatically, by passing the package name of the APK, I get the SHA256 digest. Is there anyway I can achieve it?
  • u

    user

    07/13/2022, 10:51 AM
    Error importing a framework from Swift to Kotlin in Kotlin Multiplatform I have exported a framework that consists of two classes in Swift, I have used the @objc annotation. I am trying to import it to Kotlin now and I have created a .def file with the following structure: language = Objective-C package = platform.iOSWrapper modules = SingletonFramework and in my build.gradle I've put these two: iosX64() { compilations.getByName("main") { val DateTools by cinterops.creating { // Path to .def file...
  • u

    user

    07/13/2022, 10:51 AM
    Recycler view pagination in kotlin android development Want to show images from internal storage in android studio using recycler view, did that but now want to use pagination, can it be done using pagination? class TestingAdapter(var URI_String: ArrayList, var activity: Activity) : RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val view: View = LayoutInflater.from(parent.context).inflate(R.layout.view, parent, false) return ViewHolder(view) } override fun onBindViewHolder(holder:...
  • u

    user

    07/13/2022, 11:11 AM
    Getting suggestion to use Java 8 library for Java 11 project inside Android Studio. Why? Inside build.gradle: compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 } kotlinOptions { jvmTarget = '11' } Code: implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion" kapt "androidx.lifecycle:lifecycle-compiler:$lifecycleVersion" Which line suggestion is coming: kapt...
  • u

    user

    07/13/2022, 11:31 AM
    What is the difference between setupWithNavController and setupActionBarWithNavController? According to google function documentation, setupWithNavController: Sets up a Toolbar for use with a NavController. By calling this method, the title in the Toolbar will automatically be updated when the destination changes but setupActionBarWithNavController: Sets up the ActionBar returned by AppCompatActivity.getSupportActionBar for use with a NavController. By calling this method, the title in the action bar will automatically be updated when the destination changes Assuming I set the...
Powered by Linen
Title
u

user

07/13/2022, 11:31 AM
What is the difference between setupWithNavController and setupActionBarWithNavController? According to google function documentation, setupWithNavController: Sets up a Toolbar for use with a NavController. By calling this method, the title in the Toolbar will automatically be updated when the destination changes but setupActionBarWithNavController: Sets up the ActionBar returned by AppCompatActivity.getSupportActionBar for use with a NavController. By calling this method, the title in the action bar will automatically be updated when the destination changes Assuming I set the...
View count: 3