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/17/2022, 12:41 PM
    Spring Data Rest - repository.findById not used for item resource GET I need to set some permissions on method level for my API. For this I'm adding @PreAuthorize to the methods in my repository. It works for findAll but not for findById. It seems that the method is not used at all for the route /api/repo/1 To test my instinct, I've provided a default implementation for the findBy method that always returns null and indeed, it does not seem to work however I'm not sure if the generated implementation respects my default implementation or simple overwrites...
  • u

    user

    07/17/2022, 1:01 PM
    Running itch.io game in my android app webview I have a game made with unity on itch.io I want to open and play this game in my custom android app webview. For this I'm using. myWebView.loadUrl("https://teamwood.itch.io/super-auto-pets") myWebView.settings.javaScriptEnabled = true Url is being load but on tapping Run Game nothing happen. Can I even perform this in webview
  • u

    user

    07/17/2022, 1:01 PM
    how to pass access token and refresh token to header in retrofit kotlin in koin I am developing new android app where I am making post login request but I have confused I am using koin dependcy injection how can I pass refresh token and access token after successfully response. in order to making a call interface MeloApi { @Headers("Content-Type: application/json") @POST("/login") suspend fun makeLogin(@Body loginModel: LoginModel) : Response } below my login model data class LoginModel(val username:String, val password:String) // following my base url...
  • u

    user

    07/17/2022, 1:21 PM
    How to use dynamicDarkColorScheme in jetpack compose Hey guys I have question can we override MaterialTheme.colorScheme.background to change specific color with according to theme type? Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) { Greeting("Android") } If I change of Surface(color = Color.Black) in dark theme which is showing black background but if I change white theme it showing me black background, So is there way to override colorScheme or any other alternative recommended solution for...
  • u

    user

    07/17/2022, 1:41 PM
    creating a custom serializer for large data classes I have a data class for a currency conversion rate response. I keep getting this error: Rejecting invocation, expected 76 argument registers, method signature has 78 or more ... as you can see below. (the Conversion Rates class has more than 160 currency) I"m using Ktor client, and my data classes looks like this: @Entity(tableName = "exchange") @Serializable data class Exchange( val base_code: String, @Contextual val conversion_rates: ConversionRates, val documentation:...
  • u

    user

    07/17/2022, 2:01 PM
    Kotlin + Hilt: ClassNotFoundException: Didn't find class "app.Hilt_AppSettings" on path: DexPathList First of all, and just in case, I've read plenty of posts (like this) with no luck so don't mark this as duplicate please. I'm new to Hilt, and trying to implement it in my multi-module app, but for the moment cannot even get my app to start. I have a class called AppSettings in a module called "Common" -which is accesible from all modules- which holds (as...
  • u

    user

    07/17/2022, 2:01 PM
    how to implement generated grpc code in kotlin i give up using and gradle plugin to generate the protobuf code form *.proto so i decided to use protoc -I=$SRC_DIR --java_out=$DST_DIR --kotlin_out=$DST_DIR $SRC_DIR/addressbook.proto directly i tried to follow along this repo https://github.com/benz93chung/GrpcMvvm just added this line to the head of proto file (helloworld.proto) in the repo above option java_generic_services = true; i generated the code from...
  • u

    user

    07/17/2022, 2:21 PM
    How can I change textview text with list index? I have two activities. Im going to toss a ArrayList that has random integer numbers which is made in activity1 to another activity, named ResultActivity, by intent. Then I want to change the text of textviews of ResultActivity using the index of the list which is tossed. below is a code of ResultActivity I tried. class ResultActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_result)...
  • u

    user

    07/17/2022, 3:01 PM
    How can I enclose each sentence in double quotes? I have 50 mixed sentences. How can I enclose each sentence in double quotes? I will a make list
  • u

    user

    07/17/2022, 3:21 PM
    Android: Graph from Anychart with Scrollview not displayed I am trying to use Anychart for Android in a scrollview. But as soon as I do this, the graph is no longer displayed. But as soon as I remove the scrollview the whole thing works again. Is there any idea or trick to use it in a scrollview? Below is my small test application to test and analyze the problem. package de.nieslfriem.anychart import android.os.Bundle import android.view.View import...
  • u

    user

    07/17/2022, 3:41 PM
    What can I use in java instead of run function in Kotlin? I try to convert code Kotlin to java and I could not find run function in java. This is Kotlin code : private val resumeArElementsTask = Runnable { locationScene?.resume() arSceneView!!.resume() } And I use resumeArElementsTask like resumeArElementsTask.run { computeNewScaleModifierBasedOnDistance(locationMarker, locationNode.distance) } When I convert to java private final Runnable resumeArElementsTask = new Runnable() { @Override public void run() {...
  • u

    user

    07/17/2022, 3:41 PM
    Kotlin - how can I pass a value in from activity to fragment How can I pass a value "admin" which I am extracting from a function to a settings fragment so that I can disable the button admin in the fragment
  • u

    user

    07/17/2022, 3:41 PM
    Strange behaviour on text color in jetpack compose Hey I am new in jetpack compose. I tried to set window background color black and white according to theme. When I created custom theme and set background color my text color will be black. theme.kt package com.vivek.sportsresult.ui.theme import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import...
  • u

    user

    07/17/2022, 3:41 PM
    Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ Kotlin Retrofit Coroutines For days I have had this problem that I cannot solve since it always gives me an error when loading the data from the api, Help my problem its: FATAL EXCEPTION: DefaultDispatcher-worker-1 java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ VIEW MODEL @HiltViewModel class RMViewModel @Inject constructor(private val useCase: RMGetCharacterUseCase) : ViewModel() { private val _state = MutableStateFlow(RMListState.Empty) val state:...
  • u

    user

    07/17/2022, 4:41 PM
    Activity restart when configuration changes but I used viewmodel Viewmodel class using hilt viewmodel and avoids configuration changes side effects @HiltViewModel class ListScreenModel @Inject constructor():ViewModel() { val myFlow=flow{ (0..100).forEach{ emit(it) kotlinx.coroutines.delay(1000) } } } Composable function where I use my viewmodel and try to print emitted values. @Composable fun ListValue() { val viewmodel = hiltViewModel() val num=viewmodel.myFlow.collectAsState(initial = 0).value Text( text =...
  • u

    user

    07/17/2022, 5:01 PM
    How to add suffix text into EditText after write on Keyboard on Android In my application I want use EditText and I want after user write on keyboard add suffix text into EditText. I write below codes, but when user write on keyboard application has freeze! loginPage4SelectTxt.addTextChangedListener(object : TextWatcher { override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { } override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { }...
  • u

    user

    07/17/2022, 5:01 PM
    Why my variable "inaltime" is not retaining any value from the previous fragment In SharedViewModelClass: class SharedViewModel : ViewModel() { private var _inaltime= MutableLiveData(0.0) val inaltime : LiveData = _inaltime } In the first fragment: class StartFragment : Fragment() { private var binding: FragmentStartBinding? =null private val sharedViewModel: SharedViewModel by activityViewModels() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { val fragmentBinding =...
  • u

    user

    07/17/2022, 5:41 PM
    viewModel/model not saving boolean value - android I am trying to make a call to an endpoint to onboard a user to an app. For some reason the boolean values are not being stored in my user object. The other items are fine. I'm missing something but I simply cannot see where. I'd really appreciate another set of eyes to help point out where I'm off. Thanks!! Here is my User model @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) @Parcelize class User( var userID: Int = 0, var email: String = "",...
  • u

    user

    07/17/2022, 6:01 PM
    How do I convert text in an EditText component to an integer? I am currently making a simple random number generator in Android Studio as it is my first time coding in kotlin, you put in 2 numbers, and it will pick a random number between said numbers. class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val rollButton = findViewById(R.id.rollButton) val resultsTextView =...
  • u

    user

    07/17/2022, 6:01 PM
    LazyVeritcalGrid with multiple items in compose I've LazyVerticalGrid with 2 items as bloew LazyVerticalGrid( columns = GridCells.Adaptive(150.dp), verticalArrangement = Arrangement.spacedBy(8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp) ) { item { header() } items { content() } } Content is paging data and I'm showing empty view when no data is available. However, the issue is, if i use following code, fillMaxSize() will take max size of entire grid and centering the empty view will overlap the header....
  • u

    user

    07/17/2022, 6:41 PM
    Spinner not charge list I'm getting a list of company names but I can only get Spinner to show me one item from the list. What can I do so that the spinner loads the empresa list, it only shows an item private fun initCharacter(clientes : List) { clientes.forEach{ val empresas = it.empresa val listCliente: MutableList = ArrayList() listCliente.add(SpinnerClientes(empresas)) val spnAdapter = SpinnerClientesAdapter(this@AddObra, R.layout.kecamatan, R.id.spinnerText,...
  • u

    user

    07/17/2022, 7:21 PM
    Execution failed for task ':app:kaptReleaseKotlin' When i'm trying to build my app i face this error but when i check the file its not showing any error !! ERROR:

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

    What went wrong: Execution failed for task ':app:kaptReleaseKotlin'. A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction java.lang.reflect.InvocationTargetException (no error message) <a href="

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

    "...
  • u

    user

    07/17/2022, 8:21 PM
    Redis TTL is always -1 and can't be configured in a Spring Boot application I can't configure a TTL for the bucket4j configuration. It is always -1. Has this soemething to do with the weird key serialization, see screenshot? TTL configuration does work with other but not with bucket4j. @Bean fun redisCacheManagerBuilderCustomizer(): RedisCacheManagerBuilderCustomizer { return RedisCacheManagerBuilderCustomizer { builder -> builder .withCacheConfiguration( "bucket4j",...
  • u

    user

    07/17/2022, 8:41 PM
    KOTLIN - How can I pass a parameter from activity to fragment without displaying it on the fragment I am trying to pass the value of type from activity to fragment, but keep getting null in the log. The code is as follows : Code in the activity written for passing the value to the fragment //for variable transfer to fragment val fragment=FragmentSettings() val fragmentManager : FragmentManager = supportFragmentManager val fragmentTransaction : FragmentTransaction = fragmentManager.beginTransaction() var type = snapshot.child("spinner").getValue(String::class.java).toString()...
  • u

    user

    07/17/2022, 9:01 PM
    Kotlin - Type inference in unsigned type ranges Why does this work (using signed types)... val x = 123 println(x in Byte.MIN_VALUE..Byte.MAX_VALUE) ...but this doesn't (using unsigned types)... val x = 123 println(x in UByte.MIN_VALUE..UByte.MAX_VALUE) Error produced is: Type inference failed. The value of the type parameter T should be mentioned in input types (argument types, receiver type or expected type). Try to specify it explicitly.
  • u

    user

    07/17/2022, 10:01 PM
    Why the variables nume, inaltime, greutate from SharedViewModelClass doesn't retain the values I pass throught the InputText? SharedViewModelClass: class SharedViewModel : ViewModel() { private var _nume= MutableLiveData("") val nume : LiveData = _nume private var _gen= MutableLiveData("") val gen : LiveData = _gen private var _inaltime= MutableLiveData(0.0) val inaltime : LiveData = _inaltime private var _greutate= MutableLiveData(0.0) val greutate : LiveData = _greutate private var _activitate= MutableLiveData("") val activitate : LiveData = _activitate private...
  • u

    user

    07/17/2022, 10:41 PM
    How to listen to all notifications sended using Signal R and Android I'm trying to send a notification using SignalR with android and I was able to only send from the android app to the Server but not to receive the same data that was sent. I'm using .NET6. This is how I'm trying to implement this. Program Class : builder.Services.AddSignalR(); var app = builder.Build(); app.MapHub("/notification"); Notification Class : public class Notification : Hub { public async Task SendMessage(string user, string message) { Debug.WriteLine("Hello...
  • u

    user

    07/18/2022, 1:41 AM
    I cant use class.READ in android networking, how to fix? (Android Studio, Kotlin) i want to use android networking, already make the class, but i want to use .READ, i try to import all 3 option, but all failed, what to do?

    snippetâ–¾

    snippetâ–¾

  • u

    user

    07/18/2022, 2:01 AM
    How to disable caching on RecyclerView item clicks that opens up a Fragment? I have a project that has a RecyclerView and each item click on RecyclerView will navigate you to another fragment which will load the data of the specific item from a REST API (using Retrofit2). // Overriding my onClickListener interface on my adapter override fun onMediaClick( mediaPosition: Int, mediaCategory: String, mediaId: String, mediaImage: String, mediaImageView: ImageView ) { val args = Bundle().apply { putString(MEDIA_ID, mediaId)...
  • u

    user

    07/18/2022, 2:01 AM
    + operator in Kotlin gives "Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:" I am learning Kotlin by doing exercises on exercism.com. I am currently working on triangles. The code has the following test that I'm trying to make pass: class TriangleTest { @Test(expected = IllegalArgumentException::class) fun `triangle inequality violation - last is greater then sum of others `() { Triangle(1, 1, 3) } } My solution: class Triangle(private val a: T, private...
Powered by Linen
Title
u

user

07/18/2022, 2:01 AM
+ operator in Kotlin gives "Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:" I am learning Kotlin by doing exercises on exercism.com. I am currently working on triangles. The code has the following test that I'm trying to make pass: class TriangleTest { @Test(expected = IllegalArgumentException::class) fun `triangle inequality violation - last is greater then sum of others `() { Triangle(1, 1, 3) } } My solution: class Triangle(private val a: T, private...
View count: 7