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/18/2022, 3:41 AM
    Create file format that can store video and acceleration data frame by frame Android I'm creating an Android app (using Kotlin) that can record video and other device sensory data. I want to store all of the data (the video and the acceleration sensor data) together in one file so that I can replay it the same way a regular .mp4 plays, but have access to the extra frame-by-frame device sensor info. Right now I have methods to get live sensor data and I am using CameraX for the video capture part. I already have methods to encode all my numerical sensor data into consecutive...
  • u

    user

    07/18/2022, 4:01 AM
    Kotlin serialization: nested polymorpfic moduke Recently I've been trying to implenent kotlin serialization for polymorphic class hierarchy. I used this guide, however my example was a bit more complex. I had the following class structure: @Serializable open class Project(val name: String) @Serializable @SerialName("owned") open class OwnedProject(val owner: String) : Project("kotlin")...
  • u

    user

    07/18/2022, 5:41 AM
    What is NetworkRequestHandler Class and why it's been used while working with APIs ? ✋🏻 I have seen this clsss used in many projects in which APIs are included but couldn't understand what's the use of this class. Please explain each line of this class properly. package dev.android import retrofit2.HttpException import java.net.SocketTimeoutException data class Resource(val status: Status, val data: T?, val message: String?) { companion object { fun success(data: T?): Resource { return Resource( Status.SUCCESS, data,...
  • u

    user

    07/18/2022, 5:41 AM
    How to Shuffle List Of Qoutes In Qoutes.json In Kotlin hi i am new to kotlin and want to get shuffeled my qoutes found in asset here is my peice of code private fun loadQuotesList(): Array { val inputStream = context.assets.open("quotes.json") val size :Int = inputStream.available() // find size of input stream val buffer = ByteArray(size)// define byte array and put size inputStream.read(buffer) // read byte array inputStream.close() val json = String(buffer, Charsets.UTF_8) //convert bytearray...
  • u

    user

    07/18/2022, 6:21 AM
    IntelliJ gives incorrect "Condition is always false" warning I am learning Kotlin by doing exercises on exercism.com. I am currently working on triangles. Part of my solution is like this: class Triangle(a: T, b: T, c: T) { init { require (a != 0 && b != 0 && c != 0) } } On the line with require(), IntelliJ gives the warning: Condition 'a != 0 && b != 0' is always false Condition 'a != 0 && b != 0 && c != 0' is always false I have the...
  • u

    user

    07/18/2022, 6:41 AM
    Date format using kotlin I would like to reformat a string from 14 Sep 2021 to 14 Sep using the SimpleDateFormat or any other APIs. Currently my code looks like this: private fun convertToDayAndMonth(date: String): String{ val dateFormat: Date = SimpleDateFormat("dd MMM yyyy").parse(date)!! return SimpleDateFormat("d MMM").format(dateFormat) but i am getting an error that says "14 Sep 2021" cannot be parsed
  • u

    user

    07/18/2022, 7:01 AM
    Create a card and show the user what does do this section in the app android how can create the green card in the below picture and show the user what does do section in the app android?

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

  • u

    user

    07/18/2022, 7:21 AM
    Operator called default onErrorDropped after upgrading the Spring boot version from 2.1.7 to 2.6.4 This code is running fine in Springboot 2.1.7 version but after upgrading it to Springboot 2.6.4 it throws exception. Unable to rectify the issue. Let me know where I have to change in code fun getScheduledTasks(): Flux { return Flux.fromIterable(tasks) .filter { logger.info("{} was enabled? {}", it::class.qualifiedName, it.config.enabled) it.config.enabled } .flatMap { task ->...
  • u

    user

    07/18/2022, 7:21 AM
    Как добавить затемнение экрана и добавить маленький разделитель? Всем привет, как сделать затемнение экрана при показе Bottom Sheet и сделать разделитель в Jetpack Compose? Буду очень благодарна если поможете)

    enter image description here▾

  • u

    user

    07/18/2022, 7:41 AM
    extract data from JSON response volley android I´m trying to extract data from my JSON response from php in kotlin. This it´s result from my php: Log.d(TAG, "Login Response: $response") Login Response: {"data":{"name":"david","surname":null,"email":"prueba@prueba.com","phone":null,"password":"123456"}} but when i access to this json: W/System.err: org.json.JSONException: No value for name W/System.err: at org.json.JSONObject.get(JSONObject.java:400) W/System.err: at org.json.JSONObject.getString(JSONObject.java:561) W/System.err:...
  • u

    user

    07/18/2022, 8:01 AM
    Custom Marker in RadiusMarkerClusterer I created a customMarker that in addition to the image contains a label at the bottom with a name. If I create a "FolderOverlay" everything works correctly I see my custom Marker. This is my customMarker class MarkerWithLabel(mapView: MapView?, val label: String) : Marker(mapView) { val textPaint = Paint() init { with(textPaint){ color = Color.BLACK textSize = 35f isAntiAlias = true typeface = Typeface.DEFAULT_BOLD textAlign = Paint.Align.CENTER...
  • u

    user

    07/18/2022, 8:01 AM
    Different results on similar code with safe call operator in Kotlin I'm new to Kotlin and these two below codes give different results. fun main() { var name: String? = "Denis" name = null print(name?.toLowerCase()) } Output: Compilation Error (illegal access operation) fun main() { var name: String? = null print(name?.toLowerCase()) } Output: null
  • u

    user

    07/18/2022, 8:01 AM
    How can we reduce weak hit records using Machine Learning in Elasticsearch? I just learn the Elasticsearch app instance. I build the query to search data in Elasticsearch but it seems doesn't match really well. I want to use Machine Language to reduce the weak hit records and I don't know how. Can anyone help me, please?
  • u

    user

    07/18/2022, 8:01 AM
    Gradle fails after kotlin serialization plugin update to 1.7.10 My build.gradle.kts starts as follows: ... import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { ... kotlin("jvm") //target version is java 11 kotlin("plugin.serialization") version "1.6.21" } When I try to update the kotlin serialization plugin to the more recent 1.7.10 version, I get the following compilation error: A problem occurred configuring project...
  • u

    user

    07/18/2022, 8:41 AM
    Is it possible to get combined test coverage of android Unitesting and UI testing coverage | not repeated question I have tried using jacoco for fetching code coverage but every time i am able to get 100% success also i have found that JacocoEverywhere is deprecated is there any other way to fetch code coverage. I have gone through several stackoverflow questions not able to find the answer so raising this question.
  • u

    user

    07/18/2022, 9:01 AM
    Draw a circle behind BadgeBox to make it more visible, circle getting too small My code: IconButton(onClick = { /*TODO*/ }) { BadgedBox( modifier = Modifier.drawBehind { drawCircle( color = Color.LightGray, center = Offset( this.size.maxDimension / 2, this.size.maxDimension / 2 ), radius = 10f ) }, badge = { Badge(modifier = Modifier.size(12.dp)) {} }, ) { Icon(imageVector =...
  • u

    user

    07/18/2022, 9:21 AM
    Add + symbol at regular expression kotlin [duplicate] I would like to check whether a string is equal to my expression. For example I have such string: 2022-07-18T00:00:00+02:00 I did such regular expression: Regex("\\d+-\\d+-\\d+T\\d+:\\d+:[0-9]+ \\d+:\\d+") but how I can add + between 00+02? I tried to add it directly but it didn't work at all.
  • u

    user

    07/18/2022, 9:41 AM
    Pin a view to Bottom Sheet in Jetpack Compose I'm trying to implement a persistent Bottom Sheet in Jetpack Compose which has a button that should be pinned to the bottom of this sheet at all time, it shouldn't get dragged with the other contents when expanding. I couldn't find an easy way to do it except manipulating other views heights relative to the bottom sheet state which is hard to maintain. Any idea how can I achieve that? Here's an illustration for what I'm trying to achieve <a href="

    https://i.stack.imgur.com/UqYHa.jpg▾

    "...
  • u

    user

    07/18/2022, 10:41 AM
    How to save retrofit response in shared preferences in and use it repository layer I have post method where I am sending login request to server but first I want to save that response using shared preferences in my repository how can save retrofit response in shared preferences below my interface class I have implemented login post request logic interface MeloApi { @Headers("Content-Type: application/json") @POST("/login") suspend fun makeLogin(@Body loginModel: LoginModel) : Response } below my loginModel class data class LoginModel( val...
  • u

    user

    07/18/2022, 11:01 AM
    I cannot change the progressbar's progress when i am setting progressbar max and min value How to change the progressbar's progress color when you have set max and min value of progressbar. i have a progressbar and try to set max value as 15 and min value as -5. i want to show progress from -5 to 0 as progress and change the color of progress as red and show green color as 0 to 15 to the progressbar. false 4dp 4dp
  • u

    user

    07/18/2022, 11:01 AM
    How can I make a Navigation Drawer go to the back of the Layout when Closed? In my layout xml file i have a webView and a Navigation Drawer: When I run this, I can't click on the webview at all. But if i switch the order of the webview and the navigation drawer, then i can press on the webview but i cannot open the navigation drawer (or it can't be seen). I want to be able to click and open both. How can i achieve this functionality?
  • u

    user

    07/18/2022, 12:01 PM
    How to create new Activity/fragment in kotlin folder I decided to change the java folder in my project. I renamed app->src->main->java folder to app->src->main->kotlin

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

    Then I correct the path in the Gradle by blow code sourceSets { main.java.srcDirs += 'src/main/kotlin' } problem: When I want to create new activity or fragment by the wizard, new classes are created on the java folder even if I do right-click on the kotlin for creating the folder. <a...
  • u

    user

    07/18/2022, 12:41 PM
    The program does not work on some devices Good afternoon! Such a situation, I wrote a program for Android and the following situation arises: Emulating on Nexus 5 Android 11 (API 30) - works I run on a real device Honor 9 Android 9 (API 28) - works Galaxy A50 Android 11 - working I also run it with friends on their phones and the following happens, which seems strange to me: realme 6 pro android 11 - not working Redmi Note 10 pro Android 11 - not working redmi note 10s android 11 - not working And most importantly, I can’t track the...
  • u

    user

    07/18/2022, 1:01 PM
    Secondary constructor initiation logic I have a generic data class like: data class ConfigurationDTO( val id: Long, val key: String, var value: T ) And I would like to have a constructor where I could pass the value as String and a KClass to deserialize it. The problem is Kotlin oblies me to call this() on the secondary constructor and I have no value for value yet: constructor(id: Long, key: String, valueStr: String, klazz: KClass) : this(id, key, ??????) What I would like to do is the equivalent like:...
  • u

    user

    07/18/2022, 1:01 PM
    Clearing SharedFlow: Converting flow to mutableFlow I've an API that returns flow which I'm converting to sharedFlow using shareIn(). I've a use case where I want to reset the cached value in the sharedFlow and force the flow to fetch new data. We've a resetReplayCache() however it's only available for MutableSharedFlow. class User { val _flow = SharedFlow by lazy { Api.observeData().map {result-> transformData(result) } . shareIn(scope, timeout, 1) val flow = flow fun forceFetchNewData() { _flow.resetReplayCache()// how can I...
  • u

    user

    07/18/2022, 1:21 PM
    call fragment function from listener interface? How do I call a fragment function from a listener interface like this? viewBinding.myImg.setOnPhotoTapListener(PhotoTapListener()) } private class PhotoTapListener : OnPhotoTapListener { override fun onPhotoTap(view: ImageView?, x: Float, y: Float) { val xPercentage = x * 100f val yPercentage = y * 100f Log.d("abc", "photo tap") // doStuff()
  • u

    user

    07/18/2022, 1:21 PM
    Hilt - Android - Cannot inject members into int I have an interface like below: @EntryPoint @InstallIn (SingletonComponent::class) interface Listener { fun onQuestionClicked(id: Int) } In my Adapter class for RecyclerView I have used : // bind your view here binding.root.setOnClickListener { val myEntryPoint = EntryPointAccessors.fromApplication(context, Listener::class.java) myEntryPoint.onQuestionClicked(question.id) } In my Fragment Class : @AndroidEntryPoint class QuestionsFragment: Fragment, Listener{ override...
  • u

    user

    07/18/2022, 1:21 PM
    ActionBar logo keep centered. How to make it left aligned without using ToolBar? I am using action bar and I put logo as png image there but the logo keep being centered and I want it to be left aligned. The action bar and logo code is pretty much as follows: (activity as AppCompatActivity).supportActionBar?.setLogo(R.drawable.gesit_toolbar) (activity as AppCompatActivity).supportActionBar?.setDisplayUseLogoEnabled(true) (activity as AppCompatActivity).supportActionBar?.setDisplayShowHomeEnabled(true) (activity as...
  • u

    user

    07/18/2022, 1:21 PM
    How to fetch the content of the epub file fetched using epublib I'm trying to implement Epublib library while parsing .epub file in my project. I'm able to load the file onto the web view but cannot find any way to get the content of the file to further implement it in text to speech output. Any suggestion for the same? read_aloud.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /*String editedTextReadable =...
  • u

    user

    07/18/2022, 1:21 PM
    How to handle back press on AndroidViewBinding &amp; finish host compose? The composable host an AndroidView that is a FragmentContainerView which has multiple child Fragments on back press of the FragmentContainerView we want to close the @Game composable. @Composable fun Game(data: Bundle? = null) { val user = GamingHubAuthManager.getUser().observeAsState() AndroidViewBinding(EntryPointBinding::inflate) { // val myFragment = fragmentGameContainerView.getFragment } }
Powered by Linen
Title
u

user

07/18/2022, 1:21 PM
How to handle back press on AndroidViewBinding &amp; finish host compose? The composable host an AndroidView that is a FragmentContainerView which has multiple child Fragments on back press of the FragmentContainerView we want to close the @Game composable. @Composable fun Game(data: Bundle? = null) { val user = GamingHubAuthManager.getUser().observeAsState() AndroidViewBinding(EntryPointBinding::inflate) { // val myFragment = fragmentGameContainerView.getFragment } }
View count: 3