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/20/2022, 2:21 PM
    How to get BLE ByteArray as a Hex string in Kotlin? I am relatively new to Kotlin and BLE. All i need is the Manufacturer Specific Data from a Bluetooth device. When I use 3rd party apps, I can see the raw data from the scan and it shows up as 0xFF with a value of 0x64140676071A1D0229 for example. But in my app, I get a ByteArray which looks like {5220=[B@975e5dc} for instance. How do I go from this to the Hex value I see on other apps? This is the code I use to display the data: private val scanCallback = object : ScanCallback() {...
  • u

    user

    07/20/2022, 2:41 PM
    My patch request response me 500 Internal Server Error My ViewModel function patchProfileEmailAddress fuction wants the emailAddress variable ' private fun saveUserEmailChanges(email: String?) { profileRepository.patchProfileEmailAddress(emailAddress) .onEach { when (it) { is Result.Success -> { setLoading(false) emailAddress = email updateActionState( MyProfilePersonInformationASMActionState.DismissBottomSheet)...
  • u

    user

    07/20/2022, 3:01 PM
    how many times can we call composable function in jetpack compose I need advice if I can do that or not in compose. Suppose I have A screen. Inside that I have Button. When I click on it, I am calling a api and getting the data. In this whole process I am passing UI state event i.e. IsLoading, OnSuccess and OnError. So when I press the Button the IsLoading is trigger and when I get data without any problem, I trigger OnSuccess with data. So question is When IsLoading happening I want to called A screen -> B Screen. Note:- we are standing on B screen When...
  • u

    user

    07/20/2022, 3:01 PM
    How to get diffrenet data type from Json file in android studio? How can I pull data from the following json? Model and API are below. What method should I do to see this data directly in the textview without creating an adapter? { "image": "deneme", "boxes": [ { "w": 0.2, "h": 0.1, "t": 0.1, "l": 0.2 }, { "w": 0.2, "h": 0.1, "t": 0.5, "l": 0.5 }, { "w": 0.2, "h": 0.1, "t": 0.8, "l": 0.8 } ] } Model: data class DataModel ( @SerializedName("image")...
  • u

    user

    07/20/2022, 3:01 PM
    Kotlin "None of the following functions can be called with the arguments supplied" on Fragment I'm trying to pass data from RecyclerView inside fragment to new activity, but "putExtra" displaying error like this : None of the following functions can be called with the arguments supplied Fragment.kt class NewsFragment : Fragment() { private lateinit var adapter : NewsAdapter private lateinit var recyclerView: RecyclerView private lateinit var newsArrayList : ArrayList lateinit var imageId : Array lateinit var heading : Array lateinit var news : Array...
  • u

    user

    07/20/2022, 3:21 PM
    Duplicated task error using Proguard and Dexguard together in the same build.gradle file I'm trying to use Proguard and Dexguard in the same build.gradle file (located in a android project's app module), but I'm receiving this error: Cannot add task 'collectConsumerRules' as a task with that name already exists. Does anyone know a solution for this problem?
  • u

    user

    07/20/2022, 3:21 PM
    Error when using TypeConverter with Room: Cannot figure out how to save this field into database I get this error: error: Cannot figure out how to save this field into database. You can consider adding a type converter for it. private final java.util.List stats = null; I can't figure it out. I have Added the typeconverter to the database, but still get this error. Any ideas what I do wrong? Entity: @Entity data class Detail( @PrimaryKey val id: Int, val stats: List, val types: List ){ data class Stat( val baseStat: Int, val stat: String ) }...
  • u

    user

    07/20/2022, 4:21 PM
    Jetpack Compose: force recomposition when a state changes from another activity I have two Activities: ActivityOne.kt and ActivityTwo.kt. Both of them use Jetpack Compose to display an UI. In the first one, an item (let's say, a Text) has to be shown with variable showtText is true, and hidden when it's false. I achieve this by using: @Composable fun MyUI(){ AnimatedVisibility(visible = viewModel.showText) { Text("Some text") } } My variable showText is defined in a ViewModel such as: val showText by mutableStateOf(false) That way, anytime I change...
  • u

    user

    07/20/2022, 4:21 PM
    Jetpack Compose Column Composable Alignment I'm creating a layout with Jetpack Compose and there is a column. I would like center one composable and the other to align to the bottom. Here is an image of my target screen

    hereâ–¾

    I spent day working it out, SpaceAround and SpaceBetween didn't help. I would appreciate any help.
  • u

    user

    07/20/2022, 4:41 PM
    How to show ordered and unordered list in jetpack compose? [closed] How to show ordered and unordered list in jetpack compose like this ->

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

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

  • u

    user

    07/20/2022, 4:41 PM
    TextField is cutting text at the bottom because default padding I almost completely successfully implemented the custom search component I needed, but I have one last problem. I need my component to be only 45dp to match the designer's requirements, but at that height, due to the TextField padding, it's clipping the text on top. I leave you below a screenshot of what is happening and the code I have. Is there any way to resolve this? I'm new to Jetpack Compose and that's all I need to close this component. <a href="

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

    "...
  • u

    user

    07/20/2022, 5:01 PM
    Firestore get the document but coroutine handler was called So im using coroutine on my project, and im trying to get a firestore Document using coroutine await function. And after i got the document, the handler was called even when the job was success. Anyone can explain to me how to fix it? Here is my code : val handler = CoroutineExceptionHandler { _, exception -> CoroutineScope(Dispatchers.Main).launch { Log.e(TAG, "saveData: $exception") saveData(mActivity) } }...
  • u

    user

    07/20/2022, 5:21 PM
    How do I set my media player in android studio kotlin to work with alarm volume? I am trying to get my media player to work with the alarm volume and not media volume. I have tried this, but it is not working, any suggestions? Also, am I am looking to change the sound file at some point, can the solution be used with a variable? val mediaPlayer1 = MediaPlayer.create(context2, R.raw.geese)...
  • u

    user

    07/20/2022, 5:21 PM
    Video recorder in circle shape and play it in circle shape I am trying to implement application to record video user face in left side and right side and normal in circle shape . So I am trying to play it in circle shape(custom frame) Thanks
  • u

    user

    07/20/2022, 5:41 PM
    Requestbody with formstrin is always empty I am sending a post requst via axios axios.post("path", formData ,{ headers: { 'Content-Type': 'multipart/form-data' } }); The payload of this request contains the file content as well as the name,... But @PostMapping("path") fun importCSV(@RequestPart files: MultipartFile?) = service.someaction(files) files is always null (I am using Rest api I in Kotlin).
  • u

    user

    07/20/2022, 6:01 PM
    How to deserialize List&lt;T&gt; with jacksonObjectMapper in Kotlin I am writing a generic function to retrieve data. It fetches from redis first, if there is no cache, then fetches from supplier (database). However it returns List instead of generic type List. fun retrieveWithCaching( indices: List, cacheKeyPrefix: String, supplier: (List) -> List ): List { if (indices.isEmpty()) { return listOf() } val cacheKey = cacheKeyPrefix + indices.joinToString(",") val cached = stringRedisTemplate.opsForValue().get(cacheKey)...
  • u

    user

    07/20/2022, 6:01 PM
    Instantiating ViewModel that needs application parameter causes a render problem in a composable preview My preview of a composable is not working and displaying this render problem : java.lang.ClassCastException: class com.android.layoutlib.bridge.android.BridgeContext cannot be cast to class android.app.Application My preview code : @Preview @Composable fun MainScreenPrev() { val context = LocalContext.current val application = context.applicationContext as Application val navController = rememberNavController() val myViewModel = MyViewModel(application)...
  • u

    user

    07/20/2022, 6:41 PM
    How to access scope function's parameter name with reflection I have a scope function on the Reflect class I created; this class will try to use reflection and set the status property value to the InProgress instance. My challenge here is accessing the name of status from the reflection side so I can set the private field by name. Reflect(myExampleInstance) { on { status }.then(InProgress) } ^ Here, I have status property that I have passed to the on function. This is the reflection side: inline fun on( p: T.() -> R, ): OnGoingReflect {...
  • u

    user

    07/20/2022, 7:01 PM
    Jetpack Compose - how to adjust the padding depending on the height of another component? I have a component set with Modifier.wrapContentHeight() which height has different height depending on its content. I want to adjust other component's padding to the first component height dynamically. I tried something like this: var height = 0 val resourceContentBottomPadding = height + 16 LazyColumn( modifier = Modifier.fillMaxSize(), contentPadding = PaddingValues(start = 16.dp, end = 16.dp, bottom = height.dp), ) { /.../ }...
  • u

    user

    07/20/2022, 7:21 PM
    Android Room TypeConverter to encrypt String column optionally based on other column value Given the Entity: @Entity(tableName = "otp_tokens") data class DBEntity ( @PrimaryKey(autoGenerate = true) val id: Long, val data: String, val encryptionType: EncryptionType ) EncryptionType: enum class EncryptionType { PLAIN_TEXT, ENCRYPTED } I want to use a @TypeConverter to encrypt/decrypt the data String field when accessing the database, based on the value of the encryptionType field value. So for example if encryptionType == PLAIN_TEXT the TypeConverter should...
  • u

    user

    07/20/2022, 7:21 PM
    Kotlin RPC client Is there an RPC client/library for Kotlin/JVM? I know about gRPC, but is there another one? I am trying to write an API in Kotlin for Microsoft's AirSim simulator and the python API they provide is using the msgpack-rpc library so I thought I should do something similar.
  • u

    user

    07/20/2022, 7:21 PM
    I konow why it complies errors after adding a ? safety keyword? [I do not know it complies errors. I add a ? keyword before calling length and toLowerCase()]

    enter image description hereâ–¾

  • u

    user

    07/20/2022, 7:21 PM
    How to convert string to date and then parse it to correct string output in Kotlin I get date as string from backend and now at first I need to convert it to date time and then to compare this date and current date difference in years, months, weeks, days, minutes and seconds. In JS I can do this easily with moment JS like this function extractTime(time) { return { seconds: moment().diff(time, 'seconds'), minutes: moment().diff(time, 'minutes'), hours: moment().diff(time, 'hours'), days: moment().diff(time, 'days'), weeks: moment().diff(time,...
  • u

    user

    07/20/2022, 7:41 PM
    Spring webflux javax constrains i18n not working I've made a simple reactive rest-api and now I'm trying to implement i18n for javax constraints, but it doesn't work like it does with webmvc. I created messages_en and messages_es .properties in the resources folder, added MessageSource and Validator beans from this question How to i18n a Spring RestController on java.validation constraints? but I'm still getting...
  • u

    user

    07/20/2022, 8:01 PM
    Executing query on multiple list properties I am trying to search via query stockholdersIndividual by Person that has a specific firstName or lastName matching a certain text. But at the same time, I want to ensure that the results are limited to the StockRegister with a specific reference I want to avoid using an inbuilt filter to search through the entire list to find the properties matching the input. I have tried that an it takes a very long time when there are over 10,000 records. Is there a way to do this in JPA or native query...
  • u

    user

    07/20/2022, 8:21 PM
    Execute backward query with JPA I have a query function in my repository: fun findStockholderIndividualByPersonFirstNameContainsOrPersonLastNameContains(firstName: String?, lastName: String?): MutableList? It works to some extent. However StockholderIndividual is a part of a class called Register which has attribute called reference I want to include in the query a way to say WHERE Register reference = 'XXXXX' Is this possible with JPA?
  • u

    user

    07/20/2022, 8:21 PM
    What is the best way to manage an object through a list of sequential domino operations? Let us suppose we have an Order class and a method in which some services make a sequence of operations fun doStuff(order: Order): Order { val orderByServiceA = serviceA.operationA(order: Order) val orderByServiceB = serviceB.operationB(orderByServiceA: Order) val orderByServiceC = serviceC.operationC(orderByServiceB: Order) return orderByServiceC } I create a common interface who can be implemented by the services interface IOrderService { fun operation(order: Order): Order } So the...
  • u

    user

    07/20/2022, 8:41 PM
    Ui state not working correctly in jetpack compose I am using MutableStateFlow UI State in jetpack compose. I am not getting proper flow of my UI event. In UI state there is Empty, Loading, Success and Error state. I setup a Empty state when I initialise a variable. When I am starting to call api before that I am trigger Loading state. On that basis I am triggering Success or Error event. Note: I am not adding imports and...
  • u

    user

    07/20/2022, 9:01 PM
    How to use sockets in android with kotlin? So I'm trying to use sockets in android, I've added to the manifest but I keep getting this info message I/System.out: [socket]:check permission begin! I tried with a local ftp server and I don't even see something on the server side so the connection doesn't happen at all. Here is the code (in MainActivity.onCreate() ) val connectBTN = findViewById(R.id.connectBtn) connectBTN.setOnClickListener { var con: Socket Thread { con = Socket("ftp.dlptest.com", 21) }.start() }...
  • u

    user

    07/20/2022, 9:01 PM
    How to get current date with reset time 00:00 in kotlin Hey I am using calendar instance to get current date and time. private fun getCurrentCalendar() { Calendar.getInstance() } Output:- Wed Jul 20 21:45:52 GMT+01:00 2022 If I want to reset time I need to use this function fun resetCalendarTime(calendar: Calendar) { calendar.set(Calendar.HOUR_OF_DAY, 0) calendar.set(Calendar.MINUTE, 0) calendar.set(Calendar.SECOND, 0) calendar.set(Calendar.MILLISECOND, 0) } it will give this Wed Jul 20 00:00:00 GMT+01:00 2022 My question is...
Powered by Linen
Title
u

user

07/20/2022, 9:01 PM
How to get current date with reset time 00:00 in kotlin Hey I am using calendar instance to get current date and time. private fun getCurrentCalendar() { Calendar.getInstance() } Output:- Wed Jul 20 21:45:52 GMT+01:00 2022 If I want to reset time I need to use this function fun resetCalendarTime(calendar: Calendar) { calendar.set(Calendar.HOUR_OF_DAY, 0) calendar.set(Calendar.MINUTE, 0) calendar.set(Calendar.SECOND, 0) calendar.set(Calendar.MILLISECOND, 0) } it will give this Wed Jul 20 00:00:00 GMT+01:00 2022 My question is...
View count: 10