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/04/2022, 1:31 AM
    Accurately calculating stairs / flights / floors climbed in android? This question has been asked 10 years ago without a solution so I was wondering if there’s been any change Can I calculate the number of stairs climbed using the google FIT api? Google Fit API For iOS HealthKit provides this API, it’s easy-peasy, but for android, the Google Fit API doesn’t seem to provide such information: <a...
  • u

    user

    07/04/2022, 1:51 AM
    how to do a swipeable on Material3 compose On the Material and Material2 Compose there was a SwipeableState and a swipeable option on the Modifier. But in Material3 this doesn't exist, at all. So how do you create a Swipeable in Material3? If anyone knows please share.
  • u

    user

    07/04/2022, 2:51 AM
    SpannableString not working in Kotlin MVVM I'm kinda stack here on my problem and trying to find a solution on the internet seems all of them does not work at all. I have an extension function that can add a spannable when the mail is unread. but all solutions that I found not work at all. But setting this span: setSpan(StyleSpan(TypeFace.Bold)) //
  • u

    user

    07/04/2022, 2:51 AM
    Jetpack compose from expanded bottomsheet to fullscreen Want to achieve something like in gif below using Jetpack Compose, does anyone know best soulution for this, used bottom sheet, but couldnt convert it to fullscreen

    https://miro.medium.com/max/304/1*lZTBcYUYb8eB65x_7bWbjw.gif▾

  • u

    user

    07/04/2022, 3:31 AM
    How can I use crop functionality in jet compose using registerForActivityResult? I tried may solution but I want programmatically Answer. Make sure I don't want to crop from compose in build function instead I want to select and crop image and then I want that URI.
  • u

    user

    07/04/2022, 3:51 AM
    kotlin - how to modify an integer variable newbie in kotlin and trying to solve https://leetcode.com/problems/sum-root-to-leaf-numbers/ with it. hitting a kotlin constraint that declared val are final /** * Example: * var ti = TreeNode(5) * var v = ti.
    val
    * Definition for a binary tree node. * class TreeNode(var `val`: Int) { * var left: TreeNode? = null * var right: TreeNode? = null * } */ class Solution { fun...
  • u

    user

    07/04/2022, 4:11 AM
    Pass argument with multiple return points Assuming I have a function example() that has a parameter param: Int?. I would like to call it so that the argument can be passed with certain conditionals. To try to explain better, let's define the example() function: fun example(prev: Int, param: Int?) = doSomething(prev, param) So assuming that under certain conditions, the value passed as an argument can be null or any other value. Naturally, I would do something like this: val param = if (x() > 100) null else if (x() < 0)...
  • u

    user

    07/04/2022, 4:31 AM
    Vaadin LoginForm Failure Handler Breaks login?error URL I'm using the Vaadin LoginForm with Spring Security in a Spring Boot project. By default it redirects to /login?error if authentication fails for any reason. I want to redirect for certain failures, specifically if the user hasn't validated their email yet. I'm trying to use the failureHandler feature to do this, but as soon as I create one, the /login?error URL suddenly requires the user to be authenticated, while /login functions as normal. My login view: @PageTitle("Login") @Route("login",...
  • u

    user

    07/04/2022, 5:31 AM
    Device brightness not set proper in android I want to change the brightness using seekBar it changes but the notification brightness bar progress is not the same as the progress value. public class MainActivity extends AppCompatActivity { private SeekBar seekBright; private TextView txtProgress; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); seekBright=findViewById(R.id.seekBright);...
  • u

    user

    07/04/2022, 5:31 AM
    Network Signal in android with kotlin I have a problem I have to show signal strength in an app. Just like as our mobile shows towers for poor signal strength it only shows one tower and for good signal strength, it shows all towers. In the same way, I also want to calculate the signal strength. Thanks
  • u

    user

    07/04/2022, 6:11 AM
    Dark mode not working for neumorphism in android ko I m adding code here: The library Im using is : https://github.com/fornewid/neumorphism In dark mode , its awful What should I do to solve this? Im using kotlin for my app.
  • u

    user

    07/04/2022, 6:11 AM
    define alias for gradle task with custom argument I want to run ./gradlew extractMyDeps instead of ./gradlew :app:dependencies --configuration productionDebugRuntimeClasspath but I can't pass args to this task via dependOn How to achieve my goal? task("extractMyDeps") { dependsOn(":app:dependencies") // how pass --configuration }
  • u

    user

    07/04/2022, 6:31 AM
    Can't get all documents from firebase collection with SnapshotListener I can get all documents from firebase with get() method which is not getting updates from Firestore but I can't get all documents with addSnapshotListener method. When I try to use this method it's throwing following exception : Invalid document reference. Document references must have an even number of segments, but Pairs has 1 Here is the code snippets : with snapshot listener : fun retrievePairsFromFirebase() {...
  • u

    user

    07/04/2022, 6:51 AM
    I'm getting errors in Android Studio I'm new in Android Studio and i am getting errors in Android Studio. How can I fix this? protected void onCreate(final Bundle bundle) { if (Build.VERSION.SDK_INT >= 30){ if (!Environment.isExternalStorageManager()){ Intent getpermission = new Intent(); getpermission.setAction(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION); startActivity(getpermission); } } } <a...
  • u

    user

    07/04/2022, 7:31 AM
    How to add button on Foreground Service Notification to Kill the Service on Android I am building an app on Kotlin, and when I start my foreground service, I get a notification that it is running. How can I add a button to that notification, which when clicked by the user will terminate that foreground service? private fun createNotificationChannel() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val notificationChannel = NotificationChannel( notificationChannelId, "App Name",...
  • u

    user

    07/04/2022, 7:31 AM
    How to configure SPRING-SECURITY default /admin and /login CORS with different ORIGIN? I have my frontend application localhost:3000 and my SPRING backend server localhost:8080. I have some REST Controllers and they do work perfectly fine. I have this configuration which enables CORS, so localhost:3000 (front) can call localhost:8080 (back). @EnableWebSecurity class WebSecurityConfiguration( private val myUserDetailsService: MyUserDetailsService, private val passwordEncoderAndMatcher: PasswordEncoder, ) : WebSecurityConfigurerAdapter() { override fun...
  • u

    user

    07/04/2022, 7:31 AM
    post request retrofit2 android studio kotlin i need for create user . must use request post . im use but this did'nt work and dont have error . you can see my code my server : Allow: POST, OPTIONS Content-Type: application/json { "first_name": "", "last_name": "", "email": "", "username": "", "password": "" } api.kt interface Api { @POST("users/signup") @FormUrlEncoded fun createUser( @Field("first_name") fName: String, @Field("last_name") lName: String, @Field("email") email: String, @Field("username") username:...
  • u

    user

    07/04/2022, 7:31 AM
    How to make Snackbar with custom layout in Kotlin without external libraries? I'm trying to create a custom Snackbar using my own custom layout but all examples I see, people use external libraries. Is it possible to do it without using any library?
  • u

    user

    07/04/2022, 7:31 AM
    Display the message entered by the user on next screen using kotlin How to make an Edit Text on a screen so that when we press the send button it will display the message typed by user on next screen inside a text view. I tried the following code but it gives an error message as unresolved reference: intent2. I created two activities and named them as MainActivity.kt and MessageActivity.kt and their respective layout files as activity_main.xml and activity_message.xml . 2.Inside the activity_main.xml file I made an EditText view whose id is etMessage is and a...
  • u

    user

    07/04/2022, 7:51 AM
    Setting application/json as content-type header error in Kotlin I'm trying to send a POST request to the server. When I didn't specify the content-type as header, the content-type will be x-www-form-urlencoded (I assume because I use @FormUrlEncoded). @FormUrlEncoded @POST("shiftentry/user_shift_entries") suspend fun getShifts( @Header("Authorization") auth: String, @Header("Content-Type") content_type: String, @Field("start_date") start_date: String, @Field("end_date") end_date: String, @Field("page") page: Int,...
  • u

    user

    07/04/2022, 8:11 AM
    Shared ViewModels in modules I have an Activity with multiple fragments under it. I want to share data with the Shared ViewModel, but they are all in different Modules. I can't get the ActivityViewModel Class. When I received activityViewModels() using CoreViewModel, the parent of ActivityViewModel, I got an object that was different from what I received with ActivityViewModel,How can I Share ViewModel in multiple Modules This is the log I printed after I moved them to the same Module,But that's not the way I wanted it...
  • u

    user

    07/04/2022, 8:11 AM
    Firing onClick event of child component within RelativeLayout I have an expandable list with childView layout below. I can't trigger onClick event of ImageView inside the RelativeLayout layout adapter override fun getChildView( listPosition: Int, expandedListPosition: Int, isLastChild: Boolean, convertView: View?, parent: ViewGroup ): View? { var convertView = convertView val name = (getChild(listPosition, expandedListPosition) as...
  • u

    user

    07/04/2022, 8:51 AM
    Can't use .contains() or .startsWith() in android studio kotlin project I'm new to android so bare with me.. Basically the title says it all and i found literally nothing on this issue, I get "unresolved reference" when using .contains or .startsWith, and i'm guessing many others that i don't know yet. My kotlin version is 1.4.32, says it's the latest -Worth mentioning that i went to the build.gradle file and changed "ext.kotlin_version = "1.4.32"" to "ext.kotlin_version = "1.6.0"" because it was showing an error in the IDE which said And it was solved by doing...
  • u

    user

    07/04/2022, 9:11 AM
    Action in SnackBar called instantly when show I'm trying to show my SnackBar but my action is being called instantly when shown and not when the button is clicked. Why is this happening? fun showSnackBar(msg:String,btnMsg:String,action:Unit){ SnackBar.make(binding.root,msg,Snackbar.LENGTH_SHORT) .setAction(btnMsg){ action } }.show() And thats what I do when calling this method: showSnackBar("Added","Undo",undoAction()) fun undoAction(){ //here I delete an item from a list }
  • u

    user

    07/04/2022, 9:51 AM
    KOTLIN CACHE REFRESH How to do cache clear in every 5 minutes and in 24 hours cache expires completely in retrofit API call. In java, network parse response used in the volley request. In kotlin, what should i use for it.
  • u

    user

    07/04/2022, 9:51 AM
    Turn off App-Info Battery Optimization from Kotlin I am running an app which needs to run a service in the background using IMU (accelerometer and gyroscope data) in the background, while the app is in background and the screen is off. After sometime, the IMU data stops as Android pushes the app into background. I need to disable this from inside Kotlin. As of now, the only way I found is to redirect the user to Settings.ACTION_APPLICATION_DETAILS_SETTINGS. However, from here setting the app battery settings to Do-not-optimize is different...
  • u

    user

    07/04/2022, 10:11 AM
    Using Ktor Backend for create Jasperreports i got stuck in creating PDF Reports. I created an raport with the Jaspersoft Studio. Now i want to fill the reports using my ktor backend. To activate the function i using postman. I send this [ /report/1 ] with get to my backend. as result i get this error message: net.sf.jasperreports.engine.JRException: Class not found when loading object from file: C:\path\Test.jasper. to fill the report i use this functions: fun createReport (userID: String) { val id = userID...
  • u

    user

    07/04/2022, 10:11 AM
    Kapt with Gradle, Spring Boot and Mapstruct in a multi-project not working I've moved a Java multi-project Gradle project to Kotlin. In this project I use Mapstruct. To create the required mapstruct implementation I configured kapt. Now when I start the application, Spring Boot does not find the beans from our Infrastructure Lib. When I copy the generated class of Mapstruct and remove kapt, everything works fine. Some background build.gradle in the subproject, which is using Mapstruct: apply plugin: "kotlin-kapt" dependencies { api project(":myproject-dto")...
  • u

    user

    07/04/2022, 11:11 AM
    How to create a TopAppBar in compose? I am currently trying to create a seperate composable for the TopAppBar. I am going for something like this: https://gyazo.com/029064b4fb4169c5171a85934fcdcc7a. I want to be able to customize it seperat from the drawer. How can I achieve this ? I tried to create a few following tutorials and re-search online but without any luck. I cannot figure out why it doesn't work!! @Composable fun...
  • u

    user

    07/04/2022, 11:11 AM
    How to wait result of suspend function? I need to add freshCsrf string to each request into form body. Uses OkHttpClient with AuthInterceptor. The problem is how to send request inside interceptor in order to get the freshCsrf string? In code below occurs error Suspend function 'getAuth' should be called only from a coroutine or another suspend function class AuthInterceptor(val authApi: IAuthService) : Interceptor { override fun intercept(chain: Interceptor.Chain): Response { var request = chain.request()...
Powered by Linen
Title
u

user

07/04/2022, 11:11 AM
How to wait result of suspend function? I need to add freshCsrf string to each request into form body. Uses OkHttpClient with AuthInterceptor. The problem is how to send request inside interceptor in order to get the freshCsrf string? In code below occurs error Suspend function 'getAuth' should be called only from a coroutine or another suspend function class AuthInterceptor(val authApi: IAuthService) : Interceptor { override fun intercept(chain: Interceptor.Chain): Response { var request = chain.request()...
View count: 1