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/01/2022, 9:51 PM
    How to know what version of assertEquals to use I'm working on an app in Kotlin on Android Studio. When working on a test, and I type "assertEquals" the method name is shown in red. If I type alt+enter, I get a choice of 3 versions. assertEquals(String, Object, Object) (of junit.framework.assert) assertEquals(String, Object, Object) (of junit.framework.testcase) assertEquals(String, Object, Object) (of org.junit.assert) How does one know which to choose?
  • u

    user

    07/01/2022, 9:51 PM
    How to send user to a different activity (intent is not working) *In this code, I would like to send the user to a different activity when they hit the see more button in the dropdown menu but when I try and run the line startActivity(Intent(this,home::class.java )) I get an error that says none of the following function can be called with the argument supplied * var name:TextView var mbNum:TextView var mMenus:ImageView init{ name = v.findViewById(R.id.mTitle) mbNum =...
  • u

    user

    07/01/2022, 10:51 PM
    Kotlin Change ViewText with an ID provided by a String Goal: To get a ViewText resource and edit it from an activity, using a mutable string (because then the string can be changed to alter other ViewTexts in the same function). Context: I'm making a grid using TableRows and TextViews that can be altered to form a sort of map that can be generated from an array. Issue: The binding command does not recognise strings. See my comment "PROBLEM HERE". Tried: getResources.getIdentifier but I've been told that reduces performance drastically. An excerpt...
  • u

    user

    07/01/2022, 11:51 PM
    Android Studio Getting Image From Firebase storage Hi everyone im trying to get images from Firebase Storage, each one is named after the userID, the problem and putting the images in itemListView the problem is sometimes it shows the right image for a second then it changes to the same as the other user, but it grabs all the other information right

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

    but all the arraylists i use to get the image, name and role are all correct in the same order <a...
  • u

    user

    07/02/2022, 12:51 AM
    Questions for making an app to take high resolution photos I'm trying to create a camera app using an android smartphone. The smartphone camera is a 64 megapixel camera. When you get the resolution using cameraX You can only get a camera with a maximum of 12 million pixels. I tried it on Samsung Galaxy S21. When I contacted Samsung's developer support, it seems that I can only get up to 12 million pixels. So, the question is, is there anyone using a smartphone terminal that can shoot images with a resolution of 50 million pixels or more using Camera...
  • u

    user

    07/02/2022, 1:31 AM
    Change hamburger menu from drawable to imageview I am building an app using a side menu and using supportActionBar to access to it supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_hamburger) I would like to review the R.drawable.ic_hamburger by a layout with an ImageView. The goal is to display a circle shape profile picture instead of a standard icon. I cannot find a good solution. Any idea? Thanks
  • u

    user

    07/02/2022, 2:51 AM
    Why do I get only a part of string when I use getString in Kotlin? I saved a string in resources file, I run Code A and get Result A, I hope to get the Result B. What's wrong with my code? Result A Recommend the app to a friend Code A val context = LocalContext.current val temp=context.getString(R.string.myRecommendContent) Recommend (#) the app to a friend Result B Recommend (#) the app to a friend
  • u

    user

    07/02/2022, 5:31 AM
    Get result from activity that opened with intent filter I have an intent filter like below to open specific activity when custom scheme and host called: because I don't open this PurchaseActivity via code (it's just an intent-filter that opened automatically when test://payment called) I can't call startActivityForResult, registerForActivityResult, ... inside PurchaseActivity I want to pass data to parent activity before calling finish()
  • u

    user

    07/02/2022, 6:51 AM
    Break the chain of work manager requests list for some specific condition or in case of failure I have three work requests as below val imageWorker = OneTimeWorkRequestBuilder() .setConstraints(constraints) .addTag("imageWork") .build() val gpSurveyWorker = OneTimeWorkRequestBuilder() .setConstraints(constraints) .addTag("gpSurveyWork") .build() val gpSurveyListWorker = OneTimeWorkRequestBuilder() .setConstraints(constraints) .addTag("gpSurveyList") .build() and I enqueue them in work Manager as...
  • u

    user

    07/02/2022, 7:31 AM
    !!Please Help me!! parse No Key json list with moshi in Android What I am trying to do is to get Json response from GitHub API call of user's repository list. response example from Github is like below. [ { "id": 78688034, "node_id": "MDEwOlJlcG9zaXRvcnk3ODY4ODAzNA==", "name": "py3status", "full_name": "randomguy/py3status", "private": false, "owner": { "login": "randomguy", "id": 798223, "node_id": "MDQ6VXNlcjc5ODIyMw==", "avatar_url": "https://avatars.githubusercontent.com/u/798223?v=4",...
  • u

    user

    07/02/2022, 7:51 AM
    How can I pass the checked radio button value into text View in kotlin android studio? I made a dialogue box and I put radio group in it and i add three radio button 1)male 2)female 3)others if user select male so the selected radio button male should be shown in text View
  • u

    user

    07/02/2022, 7:51 AM
    Im trying implement cast on my app but cast icon not show I'm trying to add an android cast for my android app but my cast icon does not show on my app. Here is my menu Code And this is my Cast options provider. I'm not registered with the google cast developer console so IM using CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID here class CastOptionsProvider : OptionsProvider { override fun getCastOptions(p0: Context?): CastOptions { return CastOptions.Builder()...
  • u

    user

    07/02/2022, 8:11 AM
    Kotlin Recyclerview change item color onClick i have a Recyclerview adapter in Kotlin and when i click it change the color to Red but if i click another item, the previous item still have the Red color. How to make the logic when the item click it will change Red and when click another item it will back to default color and new item become Red. this is the adapter class CategoryAdapter(private val onClick: OnClickListener): RecyclerView.Adapter() { private val diffCallBack = object: DiffUtil.ItemCallback(){ override fun...
  • u

    user

    07/02/2022, 8:51 AM
    Validating data from a database I am trying to create a registration screen. When the registration button is pressed, I want the program to check if the provided username already exists in the database. Is it does, it will not proceed with the registration. Problem is, I cannot, find a way to access the data. Here's the related code '''@Database(entities = arrayOf(User::class), version = 1) abstract class UsersDatabase : RoomDatabase() { abstract fun usersDao(): UsersDao companion object { @Volatile private var...
  • u

    user

    07/02/2022, 9:11 AM
    How to parse XML and avoid parsing errors of namespace by setting a default one? Background I'm trying to parse some manifest XML files of Android APK files The problem I've noticed that in some cases, the XML files aren't valid, meaning that many times there is no namespace being defined, or that for some XML attributes, the namespace isn't used at all. For example, this is a tiny part of Chrome APK manifest file (it's much longer): You can see that there is no namespace being defined here, and the attributes don't use one either. In some cases, the...
  • u

    user

    07/02/2022, 9:51 AM
    How to skip top key of json? There is JSON with root key playlist that fetch from Retrofit Interface. Gson library can't parse it to data class. Is there way to do "step into" playlist key before create model? { playlist: { name: "", description: "" } } data class Playlist(val name: String, val description: String)
  • u

    user

    07/02/2022, 9:51 AM
    Coverting Float to String with comma without Rounding I'm using this for adding commas into number. val commaNumber = NumberFormat.getNumberInstance(Locale.US).format(floatValue) floatValue is 8.1E-7 , but commaNumber shows just 0. How to covert Float to String with comma without Rounding?
  • u

    user

    07/02/2022, 10:11 AM
    Time taken to remove Firebase Realtime Database Listener My question is simple "how much time does it take to remove a listener?" I am asking this because when I assign a ValueEventListener to a specific place in a real-time database and remove it after the work is done. Now, if still the changes are made to the same database location where the listener was working before being removed, I still get the values and that should not happen. So, removing the ValueEventListener removes the listener instantaneously or after a while. If not then I might be...
  • u

    user

    07/02/2022, 10:31 AM
    How to pass traceId when creating new coroutine in sleuth? How to correctly pass the traceId when creating a new coroutine context? Currently the traceId and spanId is zero when launching a new coroutine. suspend fun test(event: TestEvent) { CoroutineScope(Dispatchers.IO).launch { (if anything logged here, it should have the same trace id) } }
  • u

    user

    07/02/2022, 10:31 AM
    Insert data and get back id in mybatis I should save the record in the database and get the record id in the response. After a long search and research I came up with the following option. data class User( val id: UUID? = null, val username: String, ... ) UserRepo: @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @Insert(""" INSERT INTO "user" ( username, ... ) VALUES ( #{username}, ... ) """) fun save(user:...
  • u

    user

    07/02/2022, 10:31 AM
    Caused by: org.gradle.plugin.internal.InvalidPluginIdException: plugin id 'androidx.navigation:navigation-safe-args-gradle-plugin' is invalid? I am developing new android app where I am using android navigation component but when I run the project I am getting following Caused by: org.gradle.plugin.internal.InvalidPluginIdException: plugin id 'androidx.navigation:navigation-safe-args-gradle-plugin' is invalid below my build.gradle plugins { id 'com.android.application' version '7.1.3' apply false id 'com.android.library' version '7.1.3' apply false id 'org.jetbrains.kotlin.android' version '1.6.10' apply false id...
  • u

    user

    07/02/2022, 10:51 AM
    When to update local db(coredata) from server data for particular user? I am working on mobile application in which we'll store data to local db. If a user changed his/her name or profile image from web. Then how and when, i'll update my record on local db for particular user? Either will i have to check all record one by one or any other solution. Please suggest. What should be the steps to update db?
  • u

    user

    07/02/2022, 11:51 AM
    Kotlin inline function call vs function call with default type argument Consider the following code: fun foo(type: Class = Any::class.java) { } inline fun foo() { } fun main() { foo() // ERROR! } This code causes the following error: Type inference failed: Not enough information to infer parameter T in inline fun foo(): Unit Please specify it explicitly. Why doesn't the compiler just default to the non-inlined function, with a default argument?
  • u

    user

    07/02/2022, 11:51 AM
    kotlin spring @WebMvcTest is slow I'm using @WebMVcTest for the integration test in kotlin, spring. The speed of the test varies a lot for each method, but I don't know the exact cause. Each test method code is as follows. @Test fun `test1`() { // given val folderList = mutableListOf( Folder.FolderListResponse(1L, "emoji1", "child1"), Folder.FolderListResponse(2L, "emoji2", "child2") ) every { folderService.findFolderChildList(any()) } returns folderList...
  • u

    user

    07/02/2022, 12:31 PM
    Composable does not update when mutablestateflow in viewmodel I have Viewmodel where I keep reference to post. When i want to translate post i run function to update state flow and post and if I put logs there I see that value is changed but my composable did not get any new value. Here is part of code from viewmodel that doing this magic private var originalText = tile.text?.originalText private var text = tile.text?.text private var _postTileState = MutableStateFlow(tile) val tileState = _postTileState.asStateFlow() fun...
  • u

    user

    07/02/2022, 12:31 PM
    How to iterate over a Map in Kotlin So I am new to Kotlin and I am wondering what's the standard way of iterating a Map. I have tried different ways and all of them seem to work, but I don't know if there's one better than the rest or there are some differences that I am not aware of. var mutMap = mutableMapOf("one" to 1, "two" to 2, "tree" to 3, "four" to 4, "five" to 5) mutMap.forEach { entry -> println(entry) } mutMap.iterator().forEach { entry -> println(entry) } mutMap.entries.forEach { entry ->...
  • u

    user

    07/02/2022, 12:31 PM
    Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15 I have this problem when I want to use "react-native-webview": "^11.22.4" with "react-native-video": "^5.2.0". The problem appear when I wanted to use react native video D:\Document\Nodejs\Github\trender\mobile-interface\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\events\TopShouldStartLoadWithRequestEvent.kt: (28, 21): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected...
  • u

    user

    07/02/2022, 1:11 PM
    PsiElement.firstChild vs PsiElement.children.first() I expected PsiElement.firstChild and PsiElement.children.first() to always return the same PsiElement, however, it turns out that (considering KtElements): for KtBlockExpression they are not the same: firstChild returns a left curly brace and children.first() returns the first expression of the body. for KtTypeReference they are the same thing. So the questions is: Why are they not equivalent in general? When are the equivalent and when are they different (I am interested mainly in classes...
  • u

    user

    07/02/2022, 1:31 PM
    In Kotlin how Immutable parameters affect space complexity if you have to copy the input every time to modify it? In Kotlin, function parameters are immutable, so you cannot modify the parameter in the code without making a copy first, does this affect space complexity, and does it prevent in-place modification, thus preventing it from having O(1) constant? What is the solution to this? fun replaceFirstElement(nums: IntArray, number: Int) { // not working nums[0] = number }
  • u

    user

    07/02/2022, 1:31 PM
    Which visibility modifier has lesser visibility: Protected or Internal? Which visibility modifier is more permissive: Protected or Internal? internal var num = 18 protected set // throws an error at 'protected' showing: Setter visibility must be the same or less permissive than property visibility And I try this also: protected var num = 18 internal set // throws an error at 'internal' showing: Setter visibility must be the same or less permissive than property visibility
Powered by Linen
Title
u

user

07/02/2022, 1:31 PM
Which visibility modifier has lesser visibility: Protected or Internal? Which visibility modifier is more permissive: Protected or Internal? internal var num = 18 protected set // throws an error at 'protected' showing: Setter visibility must be the same or less permissive than property visibility And I try this also: protected var num = 18 internal set // throws an error at 'internal' showing: Setter visibility must be the same or less permissive than property visibility
View count: 6