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

    06/25/2022, 8:31 AM
    How to allow to upload files in docx format in docker I have a project with a uploadBox that runs without any problem. But, when I run the project using docker, the uploadBox doesn't work. and I face an error that says I can't upload the file with docx format! When I run the project without using Docker, I don't see any file format error. I did a bit of searching and found that I had to add a config in docker-compose file to allow to upload of the files in formats like docx. I'll be grateful if you guide me.
  • u

    user

    06/25/2022, 9:11 AM
    Java calling kotlin method and expecting it to be static This java code, is calling isKeyDown method which is in the Input kotlin class and it is throwing Non-static method 'isKeyDown(int)' cannot be referenced from a static context public Boolean run() { Input.isKeyDown(GLFW.GLFW_KEY_ESCAPE); } } I tried putting the kotlin method in a companion object. the only thing is the isKeyDown method loses scope of the key[ ] array which is an in the scope of the whole class class Input{ private val keyArray : BooleanArray =...
  • u

    user

    06/25/2022, 9:11 AM
    Kotlin - Companion Object with Receiver Function I guess it's an outright "NO", but here is my class class KotlinReceiverFunction { val multiplyBy = fun Int.(value: Int) = this*value companion object { fun printMultiplicationResult(a: Int, b: Int) = a.multiplyBy(b) // error } } My question - is Receiver Function only allowed within a specific scope i.e. same as Lambdas? Or, can I get to work somehow in a companion object? Regards
  • u

    user

    06/25/2022, 9:51 AM
    How to blink flashlight using "kotlin" on button click in android studio I am an absolute beginner and just want to create an app in kotlin in which I just click a button and the flashlight of the phone blinks once please help this is urgent.
  • u

    user

    06/25/2022, 10:31 AM
    How should you work with Themes in Android? I have been practising my skills with android (Kotlin), and I am having issues with styling the UI, with most solutions here not working. It feels like there's some default style overriding what I am trying to achieve because often than not the changes are visible in the layout creator GUI in android studio but not in the app itself. I even noticed the apps base dark or light theme setting affects the Ui looks which should not be the case for me. The greatest challenge I have had is trying to...
  • u

    user

    06/25/2022, 10:31 AM
    Kotlin returns 2d Array property as reference I was messing around with Kotlin and 2d arrays an I detected a strange behavior that I don't understand. So I have a Class that has a 2d Array as property and I have another class that takes that Array and change it. But now the original Array from the property has changed. My code looks like that import org.junit.Test class ClassHasArray { val someArray = Array(3) { BooleanArray(3) } } class ClassWantsArray { @Test fun test(){ val c = ClassHasArray() val arr =...
  • u

    user

    06/25/2022, 10:31 AM
    Using ModelMapper in kotlin spring boot In few of my projects in spring boot I have used ModelMapper (https://www.baeldung.com/java-modelmapper). However now I am writing an app using Kotlin, and I couldn't find any solution that would be easier to use for converting objects from one class to another. Let's say that we have two classes like these: class Test(val name: String, val size: Int) class AnotherTest(val name: String, val size: Int, val id:...
  • u

    user

    06/25/2022, 10:51 AM
    Is the a way for SQLDelight to allow unrecognized expression? I use SQLDelight's mysql dialect on my server. Recently I plan to migrate a table to combine many fields into a JSON field so the server code no longer needs to know the complex data structure. As part of the migration, I need to do something like this during runtime - when the sever sees a client with the new version, it knows the client won't access the old table anymore, so it's safe to migrate the record to new table. INSERT OR IGNORE INTO new_table SELECT id, a, b, JSON_OBJECT('c', c,...
  • u

    user

    06/25/2022, 12:11 PM
    When adding blank fragment room db arrows appear I have a drawer layout with 3 menu points.

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

    Now i d like to add a 4th one. For this one i also need a new fragment. now when i try to create a new blank fragment and then try to run the app i get the following errors:

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

    Before adding the blank fragment everything worked fine. My worker, my room db stuff, everything. but somehow adding a new...
  • u

    user

    06/25/2022, 12:51 PM
    Firebase + Retrofit? I will buy a server, but I do not know how to write a web service. I will pull data by making a get request with Retrofit. So I'm considering working with firebase. Does it work with Firebase retroift? Can you give some information on how it works?
  • u

    user

    06/25/2022, 12:51 PM
    Change Locale Causes Extra Margins on Parent Layout(Android) I'm creating an android application that supports English and Arabic language but when I change the locale to Arabic, weird margins appear on each main layout in each activity or fragment. any can explain please what is happening?! Note: I'm using LocaleHelper
  • u

    user

    06/25/2022, 12:51 PM
    Unresolved reference: AppCompatActivity and ActivityMainBinding I am trying set up a minimal project to serve as base to future developments to work with gradle (version 7.4.2), kotlin (version 1.6.21) and vscode. I have this main activity right now: package org.kleber.minimal; import androidx.appcompat.app.AppCompatActivity import org.kleber.minimal.databinding.ActivityMainBinding import android.os.Bundle class MainActivity : AppCompatActivity() { private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState:...
  • u

    user

    06/25/2022, 12:51 PM
    RoomDataBase Empty in device file explorer When I look at the databases file in device file explorer the folder is empty. I have tried to fix the problem myself but I haven't been able to since I'm quite new to android development. This is all the code that has been written so far: Any help would be greatly appreciated. Main Activity package com.example.todoit import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import androidx.recyclerview.widget.LinearLayoutManager import com.example.todoit.data.Todo import...
  • u

    user

    06/25/2022, 1:11 PM
    How to parse two data list from one PagingData Source in Android Kotlin? This is My ViewModle Class @HiltViewModel class MainViewModel @Inject constructor( private val movieRepository: MovieRepository, private val favMovieRepository: FavMovieRepository ) : ViewModel() { ... private var _movieState = mutableStateOf(false) val movieState = _movieState val nowPlayingMovies: Flow = Pager(PagingConfig(pageSize = 10)) { MoviePagingSource(movieRepository) }.flow...
  • u

    user

    06/25/2022, 1:31 PM
    Aws SecretManager kotlin . Hide Credentials I have my Github and Artifactory Credentials stored in my local.properties file. I want to shift these credentials to AWS SecretsManager. I am using these credentials in my build.gradle.kts file and I want to retrieve my credentials from aws Secrets manager and then use them. I can think of Storing some details of the secrets manager in the local.properties file. But I can't find how to call the API for getting the secrets. I have installed this jar file...
  • u

    user

    06/25/2022, 1:51 PM
    Why it says "lateinit property resendToken has not been initialized" for jetpack compose project? I have phone authentication project in android jetpack compose, so I can do it in my code and I am success to get OTP code from firebase, but I want to use resend code again in my project, so when I click this line of code; .clickable { modelAuthentication.resendCode(phoneNumberOTP)} it is throw an error like "lateinit property resendToken has not been initialized", I am not get it what I missed, any idea? PhoneVerify.kt @Composable fun PhoneVerifyScreen( navController:...
  • u

    user

    06/25/2022, 1:51 PM
    How to open a settings page specific to devices using activity name or package name? I have a system settings activity called .settings.AppLockSettingsActivity and I want to launch that settings page when my app launches. App is a simple launcher doesn't show other pages except the settings.
  • u

    user

    06/25/2022, 2:51 PM
    Manual delete from Internal storage not working I am developing an app where am saving logcat to .txt file in Download folder using below code: val appDirectory = File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) .toString() + "/testApp" ) val logDirectory = File("$appDirectory/logs") val logFile = File(logDirectory, "testLogcat.txt") if (!appDirectory.exists()) { CxmLogs.setLogLevel(Log.ERROR) appDirectory.mkdir() } if...
  • u

    user

    06/25/2022, 3:31 PM
    Why is intent.remove extra not working as you would think? I am trying to change the value of an intent extra. I associate the value alarmId with my intent by using intent.putextra("alarmId", id). I am trying to reassign the id value the line above where I assign the value so I can reuse the alarmId text key. I've tried intent.removeextra("alarmId"), but it does not seem to do anything. I'm away from computer atm, so I don't remember if it is exactly that method, remove extra. But the one the ide recognizes does not work. Neither does setting the...
  • u

    user

    06/25/2022, 3:31 PM
    How to use Adapter.notifyDataSetChanged() in MainActivity? I have created a list with a RecyclerView, and would like to be able to update this now in the MainActvitiy, the context comes from a fragment which comes from the MainActivity, but I just can't use Adapter.notifyDataSetChanged() In the fragment it works, and it updates the list, how do I get the context from the fragment b.z how can I use Adapter.notifyDataSetChanged() also in the MainActvitiy? Adapter.kt class Adapter(val context: Context) : RecyclerView.Adapter() { var dataList =...
  • u

    user

    06/25/2022, 4:51 PM
    How to save the results from two different APIs to one Room database table? The solution method came to my mind. I could display the data in a single recyclerview using MergeAdapter however I could do this with two different database tables.
  • u

    user

    06/25/2022, 5:31 PM
    How to express union types in Kotlin? Union types, also known as sum types are a powerful language feature that I find myself using often in TypeScript something along the lines of: let a: string | number = “hello” a = 3 How would I achieve this type of behavior in kotlin? I saw some people talking about using inheritance and sealed classes to accomplish this but it looks like if you want to use that approach with primitives (such as String and Int) then one would have to write wrappers around those types to access the...
  • u

    user

    06/25/2022, 5:51 PM
    Jetpack Compose detectDragGestures seems to be working only when Canvas modifier is set to fillMaxSize or matchParentSize inside a Box I am creating a project where I have to move around Canvas elements(circles and lines) on drag gestures. I am using a Box composable to put different Canvas(s) inside it. And then with the help of pointerInput modifier I want to detect drag Gesture and hopefully achieve the behaviour I want. Box( modifier = Modifier .fillMaxSize() .padding(paddingValue),...
  • u

    user

    06/25/2022, 5:51 PM
    Parent job is completed with Ktor I run several Ktor operations in viewModelScope and getting Parent job is completed. When i run single operation everything works fine. I thought that the problem is caused by multiple runs of the scope and their incompletion. I tried running the tasks asynchronously, but I get the same issue. tasks in ViewModel: init { getCurrentConditions() get12hoursForecastResponse() get5daysForecastResponse() } fun updateLocation(location: Location) {...
  • u

    user

    06/25/2022, 6:51 PM
    Efficient way to create like 1000 instance of a class As a newbie in Kotlin, i want to ask a question. Let’s say that i have class Dog like below, data class Dog(val breed : String, val gender : String, val name : String, val age: Int){} I want to make 1000 instances of this Dog class and add all of instances in an arrayList and later i will use this list in different activities. Imagine that I have an activity which only shows Labradors . So i have to take that arrayList which contains all of my Dogs and filter the breed according to Labrador...
  • u

    user

    06/25/2022, 6:51 PM
    How to observe within Viewmodel in Android Kotlin? Below is my viewmodel class body private var _movieState = mutableStateOf(false) val movieState = _movieState private val query = if (_movieState.value) ListState.POPULAR_PLAYING else ListState.ALL_PLAYING val moviesData: Flow = Pager(PagingConfig(pageSize = 10)) { MoviePagingSource(movieRepository, query.string) }.flow And I have Two function which populate the Boolean value fun setListToPopular(){ _movieState.value = true } fun...
  • u

    user

    06/25/2022, 6:51 PM
    No adapter attached; skipping layout in kotlin **Anyone please tell me why I face this problem E/RecyclerView: No adapter attached; skipping layout in kotlin MainAcitivity :** package com.example.masgeernew import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.Menu import android.view.MenuItem import androidx.recyclerview.widget.RecyclerView import com.google.firebase.auth.FirebaseAuth class MainActivity : AppCompatActivity() { private lateinit var userRecyclerView: RecyclerView private lateinit...
  • u

    user

    06/25/2022, 7:31 PM
    Kotlin How to update nested Data Classes containing Lists I'm lacking some knowledge when it comes to updating nested Data Classes in Kotlin Here is my MutableStateFlow of type UserStateModel: private val _userStateFlow: MutableStateFlow = MutableStateFlow(UserStateModel()) val userStateFlow: StateFlow = _userStateFlow Here is my UserStateModel: data class UserStateModel( val uid: String? = null, val username: String? = null, val profileImageUrl: String? = null, var isLoggedIn: Boolean = false, val isPremiumUser: Boolean =...
  • u

    user

    06/25/2022, 7:31 PM
    Is there a "double" try and catch block? Is there a way to use a try and catch in kotlin like this try { // First try, if it throws an exception, try next try block } try { // Second try, if it throws an exception, too, go to exception block } catch (e: Exception) { // Handle exception } Thanks.
  • u

    user

    06/25/2022, 7:31 PM
    How gradle plugin ids are formatted? Android project template in Android Studio generates two build-gradle files. One for the project and one for app module. In project level build-gradle file, it contain these lines: plugins { id 'com.android.application' version '7.2.1' apply false id 'org.jetbrains.kotlin.android' version '1.6.21' apply false } In app level build-gradle file, it contain these lines: plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' } I can understand these, project...
Powered by Linen
Title
u

user

06/25/2022, 7:31 PM
How gradle plugin ids are formatted? Android project template in Android Studio generates two build-gradle files. One for the project and one for app module. In project level build-gradle file, it contain these lines: plugins { id 'com.android.application' version '7.2.1' apply false id 'org.jetbrains.kotlin.android' version '1.6.21' apply false } In app level build-gradle file, it contain these lines: plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' } I can understand these, project...
View count: 5