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/13/2022, 11:31 AM
    Run ViewModel method as a reaction on composition I have a top-level composable representing some app screen, which uses 2 view-models (for clarity). ViewModel_B starts some network activity once created: Once network request finishes, it updates state_B: MutableStateFlow inside ViewModel_B which is observe from our composable. And that state is, for example, Loading | Error | Success enum, and let's say Success contains some payload: When it's Success, I want my ViewModel_A to start another activity, which would in turn affect another...
  • u

    user

    07/13/2022, 12:11 PM
    How to properly get results from mlkit? I'm working on my first android app and I'm trying to do some OCR using mlkit. I've written a class that receives several images, analyses them and save results in a room database, and this part works. However I can't get the return on the code that uses the class (I'm assuming because it's async - correct me if I'm wrong). Here's the code where I call my class: override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState)...
  • u

    user

    07/13/2022, 12:11 PM
    Compose component inside xml is not redrawn when fragments are being replaced I have added a compose component in a custom view XML which is added from a fragment, where the project is using a navigation graph library. But when I navigate from this fragment and come back the UI(XML) will be restored except the composed component inside it. It looks like the entire UI is getting redrawn without the collapse component when the fragments are being replaced. compose component inside xml ... ... and setting up here...
  • u

    user

    07/13/2022, 12:11 PM
    Retrofit ScalarsConverterFactory.create() doesn't effect to error "Expected a string but was BEGIN_OBJECT at line 1 column 2 path $" I am trying to get request from a currency API and it's Json type is like this. { "eur":{ "code":"EUR", "alphaCode":"EUR", "numericCode":"978", "name":"Euro", "rate":0.99540765179992, "date":"Tue, 12 Jul 2022 23:55:01 GMT", "inverseRate":1.00461353516 }, Here is the link of JSON http://www.floatrates.com/daily/usd.json Even I try some solutions on here I couldn't effect to that error below...
  • u

    user

    07/13/2022, 12:11 PM
    Is it possible to remove bottomNavigation Bar while moving from one fragment to another fragment? I want to remove bottom Navigation bar while moving from one fragment to another fragment. This is how I am trying to remove bottom Navigation bar. class LoadFragment : Fragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { // Inflate the layout for this fragment val view = inflater.inflate(R.layout.fragment_load, container, false) val bottomView =...
  • u

    user

    07/13/2022, 12:51 PM
    Why covariance is needed in the following example? This might be a dumb question but I cannot wrap my head around this example: open class Case {} class InheritedCase: Case() fun getCase(): Case = InheritedCase() Can someone explain why out must be specified and why a compile error is thrown when only using String?
  • u

    user

    07/13/2022, 12:51 PM
    Saving SQLite database in Excel format I am writing an application on a Boiler in which data is saved to a database, I know that the database is saved in a folder that is not accessible to the user or other applications, and the question is: is it possible to implement the database saving function in the application in csv or excel format, so that later it could be transferred to a computer. Is this possible? If so, how to do it in Kotlin? And is it possible to transfer the edited data back to the database after editing on the...
  • u

    user

    07/13/2022, 12:51 PM
    How to check if one composable is on the same y position to another? (Arrow indicates to element from the scrollable column) I want to change the item image (above the arrow) depending on the pokemon on the right. User can vertically scroll items. I need to get the item which the arrow indicates on and handle indicated item change caused by scroll. Example: arrow indicates on "Vaporeon" User scrolls to "Jolteon" (this yellow item) While the user is scrolling, the image above the arrow should change to an image related to "Jolteon" at the moment of starting indicating on him Image stays as is until the arrow is...
  • u

    user

    07/13/2022, 12:51 PM
    Why do I get classNotFound exception Although I have added my class name in manifest? I am trying to implement Dagger hilt in my project for dependencies injection. I have MyApplication class which extends Application ,I have added this app in manifest.xml file too ,When I build the code every thing works fine, but when I run it my app crashes with below errors. It throws run time exception with class not found exception . Error 2022-07-13 18:30:42.953 23036-23036/? E/pendencieinjec: Unknown bits set in runtime_flags: 0x28000 2022-07-13 18:30:43.414...
  • u

    user

    07/13/2022, 1:11 PM
    Runtime JAR files in the classpath should have the same version. These files were found in the classpath: I have problem with pipeline test on branch and master although it used to pass on the master before. Today i update Android Studio, this can this can cause errors? I run on branch: ./gradlew assemble i get error: w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath: /Users/ddlugosz/.gradle/caches/transforms-3/d749d7039f211123753228b7812f7d3e/transformed/jetified-kotlin-stdlib-jdk8-1.5.10.jar (version 1.5)...
  • u

    user

    07/13/2022, 1:51 PM
    How to mock a binding method in Dagger 2? So, I'm trying to test my Dagger2 application with Espresso; to make quality tests I'm mocking some of the services using Mockito with DI. So far, I've been able to do it straight forward, until I had to mock a @Binds-annotated method and received this error: Binding methods may not be overridden in modules Am I misunderstanding something? What is the proper way to approach this? Here's a little example to help understand my situation: @Module(includes = [XBindingModule::class]) open class...
  • u

    user

    07/13/2022, 1:51 PM
    How to zoom on a specific image from url on webview AndroidStudio By using a Webview I'm trying to display only the QRcode from this url: https://app.ethiomobilemoney.et:2121/ammwebpay/#/?transactionNo=202207131604471547205398120337410 which is located at the center of the webpage. So my idea was to zoomIn on the webpage until only the qrcode is visible. This is my xml file. ' And this is my java code: public...
  • u

    user

    07/13/2022, 1:51 PM
    how can i solve GoogleApiManager SERVICE_INVALID for App with Location permission? i'm new to coding and as a final project on a course I decided to build and Android app, since it's what I want to focus my studies later (kinda regret it now...). My idea is about an app that will have GPS services and actions based on GPS locations, so I started following tutorials from the basics up, now i'm following a basic tutorial about a GPS app (in Kotlin) that just displays the current location with an on/off switch. I'm still getting familiar with Android Studio and all the methods...
  • u

    user

    07/13/2022, 2:11 PM
    How can I add items sepratedly from childlayout? I develop a calculator, I have to add constraints and variables, but at the end of the constraints I just want to add spinner, how can I add spinner just at the end of constraints? I am using just one child_layout

    Screenshotâ–¾

    Screenshotâ–¾

    screenshotâ–¾

  • u

    user

    07/13/2022, 2:11 PM
    Observe the state of a Worker withou LiveData So, I am using workmanager to retrieve data from an FTP server. I have to display one type or information or another type deppending on the state of the worker. I was using getWorkInfoByIdLiveData on the viewmodel and I was observing the state of the worker on the activity. But, as the Observer is almost deprecated I am trying to use Flow instead. The problem that I have is that I don't know why, I can't use the asStateFlow() on the livedata. <a href="

    https://i.stack.imgur.com/79OVt.jpgâ–¾

    "...
  • u

    user

    07/13/2022, 2:31 PM
    MaterialAlertDialogBuilder with custom itemsText I use a MaterialAlertDialogBuilder which display as:

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

    But I would like to display it more like button:

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

    I already tried to use a custom listItemLayout() but it doest not change the layout. I tried to put an array of button instead of text but in this case I can not catch the click on the button. My actual code is: val itemsText =...
  • u

    user

    07/13/2022, 2:31 PM
    Is there any opposite of the findFirst() in a stream? in my java application i use the following stream: columns.stream().map(columnEncryptors::get).findFirst().ifPresentOrElse(columnEncryptor -> columnEncryptor.encrypt(bankTransaction), () -> {throw new IllegalArgumentException("No encryptor");}); The list met columns contains 9 strings, but he is only using the first one and not the other 8. Is there a operation that can do this? Thanks! :)
  • u

    user

    07/13/2022, 2:31 PM
    error message showing on Oncreate function in the android studio I have tried searching the internet but didn't got much help . if anybody know how to resolve this please help. the error image is in the link please have a look at it. in this jam creating sign-up page whenever I am clicking on the signup button to go to signup page the app closes automatically and this 👇👇 errormessage is shown. at com.example.projectmanagementfnc.SignupActivity.onCreate(SignupActivity.kt:13) // XML file [enter image description here][1]...
  • u

    user

    07/13/2022, 2:31 PM
    Preventing mistakes with property declaration order I'm looking for a way to prevent problems in Kotlin with the order of property initialization. One of my biggest loves of Kotlin is all the ways you can lean on the compiler to prevent errors. But in this case it falls flat. Here's an example class Test{ val b = computeB() val a = computeA() private fun computeA() = 4 private fun computeB() = a + 1 } fun main(args: Array) { val a = Test() println("value of b: " + a.b) println("value of a: " + a.a) } In this...
  • u

    user

    07/13/2022, 2:51 PM
    Maven Compiler Throws Kotlin Version Error I am trying to build a Kotlin project on maven. I am using the kotlin-maven-plugin version 1.7.10. But every time I run mvn clean install -e, I keep getting the error: Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.1.16. Now I will be honest, I dont know much about Kotlin. So some pointers on this would nice. I have tried adding the apiVersion tag in the plugin and set it to 1.3, but that did not...
  • u

    user

    07/13/2022, 2:51 PM
    How can I put a parent value into a child object using Jackson JSON deserialization with Kotlin? let me prephase this by saying that this question is similar to Reuse value from parent object to construct child when deserializing with Jackson, but different enough that I think it warrants a new question. Like in the original question, I'm having the same problem that I want to repurpose a field set on an outer JSON object on a inner object when...
  • u

    user

    07/13/2022, 2:51 PM
    How to check how many ' ' empty spaces in the String - Kotlin I got a string Hello I am Android how can I count how many empty spaces in this string? So I need it return Int value 3
  • u

    user

    07/13/2022, 3:31 PM
    Jetpack compose Drawing over shapes I have this interesting problem in a project, where user should be able to draw the same shape over the defined shape, i have achieved this so far, but i want to check if he/she drawn over the shape correctly in ONE GO. if the finger goes outside the sqaure the current drawing should reset and put a toast message as unsucssesfull else says succesfull, How do i check if the drawing is on the Square?

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

    The white square...
  • u

    user

    07/13/2022, 3:31 PM
    How do you define private instance variables in Kotlin? So im trying to define a private class in kotlin/android studio. Am not sure what is going on, but i tried searching up videos on how to create a private class on kotlin. I stil don't think I know what to do. Any help? package com.example.calculator import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.View import android.widget.EditText class MainActivity : AppCompatActivity() { private EditText display
  • u

    user

    07/13/2022, 3:31 PM
    testing the diff between coroutin and thread, I can't get the OOM error when using thread in kotlin I'm studying coroutine now, and testing some difference with thread. stydying with the kotlin docs, I copied some test code and changed the code for testing thread. the docs said https://kotlinlang.org/docs/coroutines-basics.html#coroutines-are-light-weight If you write the same program using threads (remove runBlocking, replace launch with thread, and replace delay with...
  • u

    user

    07/13/2022, 3:31 PM
    Align Text and Image vertically inside Row in Compose I've got a Row with a star Image and some Text inside. I've been trying to make them align vertically whilst keeping the Text height flexible but they're always a bit off (see screenshot). @Composable fun MyRating() { Row( modifier = Modifier .background(color = Color.Green) .wrapContentSize(), verticalAlignment = Alignment.CenterVertically ) { val text = buildAnnotatedString {...
  • u

    user

    07/13/2022, 3:51 PM
    video disappears when setting match_parent in webview I have a webview in which video is played, if you set the size of the webview, for example, 200 to 200, then everything is ok, but when installed programmatically android:layout_width="match_parent" android:layout_height="wrap_content" then the video disappears from the screen, the screen becomes black. While the stream from the video continues to play as the music from the video continues to play. How I can fix it ? ......
  • u

    user

    07/13/2022, 5:51 PM
    Is Google's ML Kit available outside of Android? I'd like to use the barcode scanning functionality that comes from Google's ML Kit outside of Android (in my own Kotlin application that will run on a server). Is that even possible? If yes, how? I successfully imported it using Gradle but Gradle downloads these .aar files which I suppose are not compatible with regular Kotlin projects.
  • u

    user

    07/13/2022, 6:11 PM
    Koltin inner class extends inner class in outer class with parallel hierarchies but give Unhandled JavaScript exception class QualifiedCalls { var name = "QualifiedCalls" open inner class Outer1 { open var name = "Outer1" open inner class Inner1 { open var name = "Inner1" var superResult: String constructor() { this.superResult = this.name + this@Outer1.name + this@QualifiedCalls.name } } } inner class Outer2 : Outer1() { override var name = "Outer2" inner class Inner2 : Inner1 { override var name = "Inner2" var result: String...
  • u

    user

    07/13/2022, 6:31 PM
    Request Location Permission Doesn't Repeat for a Rejection by User I am trying to request a user's location. The first time I request a user's location, it works as intended, with a permission rationale dialog that pops up and then the user is given a choice between fine and coarse location permission. However, if the user rejects the location permission, and then clicks on the find location button, I want the dialog to pop up again, however nothing happens. It seems like the OS is storing the user's choice, and not allowing for another attempt at finding...
Powered by Linen
Title
u

user

07/13/2022, 6:31 PM
Request Location Permission Doesn't Repeat for a Rejection by User I am trying to request a user's location. The first time I request a user's location, it works as intended, with a permission rationale dialog that pops up and then the user is given a choice between fine and coarse location permission. However, if the user rejects the location permission, and then clicks on the find location button, I want the dialog to pop up again, however nothing happens. It seems like the OS is storing the user's choice, and not allowing for another attempt at finding...
View count: 4