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

    07/16/2022, 7:01 PM
    java/kotlin Normalizer fails to normalize some accented letters I noticed that the Normalizer leaves some non-ascii letters alone, such as the first letter in the name of the Polish city Łódź. Here are some more: import java.text.Normalizer fun main() { for (i in 0xC0..0x170) { val ch = Char(i) if (!ch.isLetter()) continue val norm = Normalizer.normalize(ch.toString(), Normalizer.Form.NFD) if (norm.length >= 2) { // println("'$ch' => '${norm[0]}' ${norm[0].code} '${norm[1]}' ${norm[1].code}") }...
  • u

    user

    07/16/2022, 8:21 PM
    Android Kotlin - Saving Preferences (key value pair) - not working for me I am trying various simple Android Kotlin examples, to save some persistent data in my app. To start, I am using a straight forward example of writing one key-value pair, and reading it back. here's my code, in my activity's OnCreate() val sharedPrefFile = "MyPrefFile" val sharedPreferences: SharedPreferences = this.getSharedPreferences(sharedPrefFile, Context.MODE_PRIVATE) fun setPref() { val editor = sharedPreferences.edit() val myName = "Elvis"...
  • u

    user

    07/16/2022, 8:41 PM
    Android Studio Database inspector icon does not be shown im learning using room database in kotlin but i cannot see database inspector icon in android studio. has anyone any solution ?

    The picture of my android studtio home page▾

  • u

    user

    07/16/2022, 9:21 PM
    How to export canvas to Png image and save it to gallery in jetpack compose? I created an application for image editing. I create some effected-on images from the gallery but can't save them after editing them. This is an example of a canvas that I want to save as png. var resizedBitmap: Bitmap? = null Canvas(modifier = Modifier.fillMaxSize(0.75f)) { val canvasWidth = size.width val canvasHeight = size.height with(painter) { draw(painter.intrinsicSize) } drawRect(black, size = size.copy(width = size.width /...
  • u

    user

    07/16/2022, 9:41 PM
    Kotlin Android - adding values to data class error, Why would it cause my app to crash I am trying to have a grid layout in a recyclerview to show and image text and a double variable. The goal is to add a search bar that will display the results to the recycleView. I am new to kotlin so forgive me if the problem is obvious. I am not sure exactly what is causing my app to crash, but I narrowed it down to 1 line of code in my MainActivity.kt dataList.add(mealData("mealTitle.toString()", Restaurant.toString(),R.drawable.food1,"mealCat.toString()",...
  • u

    user

    07/16/2022, 10:41 PM
    Converting Kotlin to swift get out of index error I a. trying to convert my Kotlin code to swift but I got an Index out of range error any help is appriatcted. Swift func getMaxBeauty(arr: [Int]) -> Int { // Write your code here let n = arr.count var beauty = 0 var leftMax = Array(arrayLiteral: n) leftMax[0] = arr[0] for i in 0...n { leftMax[i] = max(leftMax[i - 1], arr[i]) } var rightMin = Array(arrayLiteral: n) rightMin[n - 1] = arr[n - 1] for i in (n - 2)..
  • u

    user

    07/16/2022, 11:21 PM
    ProcessBuilder command with single quote fails I have the following code: val process = processBuilder .command(listOf( "curl", "--location", "--request", "GET", "$url", "--header", "'Authorization: token xyz'" )) Running this will result in the command failing, It's actually not picking up the header properly. I know the curl is good, because printing the command and executing it directly in terminal...
  • u

    user

    07/17/2022, 12:41 AM
    Fill the space at the bottom of screen in AlertDialog I have used a constraint layout and set both height and width to match_parent but still, there's some space I can't seem to get rid of. And also I'm using this layout for an AlertDialog. I tried creating a style for it but that doesn't seem to work either. Does anyone know how to fix this? Layout: AlertDialog: val view = View.inflate(this, R.layout.no_internet_alert, null) val builder = AlertDialog.Builder(this,...
  • u

    user

    07/17/2022, 2:21 AM
    Cannot make chat bubble after second without arrow also the time setting with text Hello i cannot make chat bubble for one message with arrow and after that without arrow until the other will send message like in WhatsApp messages screen also I am not able to do the mechanism for timing and text to be shown in same row while message characters are more it will move to second line as shown in screenshot. Please anyone who have make any chat app share its solution

    enter image description here▾

  • u

    user

    07/17/2022, 2:41 AM
    what's the difference of the kotlin version between gradle setting and IDE? I'm wondering of the difference of the kotlin version between gradle setting and ide. I can see the kotlin version of IDE(Tools -> Kotlin -> Configure Kotlin). And there is another kotlin version defined in build.gradle. I want to know the difference. I think that the version in buidl.gradle affects to real project and some dependencies. And the version in IDE affects when we wrtie the code. Is my guess is right?
  • u

    user

    07/17/2022, 5:21 AM
    mockk calls original class only instead of mockked results I have this class that I need to test. I am thinking it is because I am creating a new instance of the class A: class A { fun getName() = "Name" } class B { private a = A() fun amend(){ return "${a.getName()}-BName" } } Now I want to test class B in BTest.kt @Test fun amendTest(){ val b = B() val cls = mockk<A>() //everytime getName is called return empty string every { cls.getName() } returns "" //call ammend method val...
  • u

    user

    07/17/2022, 5:41 AM
    Kotlin convertion to and from the byte array Recently I'm trying to make a byte array from an object of class containing a few variables of primitive types. The problem has began with saving a double to the 8-byte format. After getting it back retrieved value isn't the same but kind of very close. First I checked such expression val value = Double.fromBits(1.2.toBits()) and it gave me a correct answer. So, I guess there's something wrong with my implementation of moving long integer into byte array but I can't find the bug. Samples...
  • u

    user

    07/17/2022, 6:21 AM
    gRPC response error : Unknown return value type: java.lang.Double while response value is correct I am working on a project based on Microservices architecture also have implemented a gRPC communication between internal services. I have implemented a grpc-interface module which contains my .proto files and I will add it to my microservices as submodule. Here is my build.gradle file for my grpc-interface module: buildscript { ext { protobufVersion = '3.19.1' protobufPluginVersion = '0.8.18' grpcVersion = '1.44.0' protobufJava = '3.19.4' } } plugins...
  • u

    user

    07/17/2022, 7:41 AM
    Android: Unable to go back to previous page in Webview I'm loading a url in WebView which has a flow of 3-4 screens but I'm unable to go back to previous page even if it's available. I'm using below code in the fragment to load url in webview. binding.webView.settings.javaScriptEnabled = true binding.webView.settings.minimumFontSize = resources.getInteger(R.integer.webView_small_font_size) binding.webView.settings.javaScriptCanOpenWindowsAutomatically = true binding.webView.setOnKeyListener(object : View.OnKeyListener {...
  • u

    user

    07/17/2022, 8:21 AM
    How to extract content of Mono and set to a variable in Kotlin? I have a function foo() that return Mono I want to store the String output in a variable e.g. - fun foo(): Mono { return Mono.just("Hello") } fun consumeFoo() : String { val result : String = // Set this variable to "Hello" by calling foo() } In this case how to set result to string inside Mono ? Note - I want to achieve this in a non-blocking way
  • u

    user

    07/17/2022, 8:41 AM
    Smart algorithm to randomize a Double in range but with odds I use the following function to generate a random double in a specific range : nextDouble(1.50, 7.00) However, I've been trying to come up with an algorithm to make the randomization have higher probability to generate a double that is close to the 1.50 than it is to 7.00. Yet I don't even know where it starts. Anything come to mind ? Java is also welcome.
  • u

    user

    07/17/2022, 9:01 AM
    Android Sound Localization Does anyone know how to do sound/media Localization in android like we do with strings translations to support different languages in the app? because i didn't find any good resources for this feature.
  • u

    user

    07/17/2022, 9:21 AM
    How to handle frequently changing row in recycler view in anroid I am working on a tool that list device based on certain value and the signal is on of them defined by RSSI value rssi Here this(RSSI) value changes frequently which keeps updating the rows in the recycler view. I have just started with recycler view and by looking internet I am using a list adapter with diffutil callback. But it behave the same here is example...
  • u

    user

    07/17/2022, 10:01 AM
    Android Kotlin retrigger retrofit api call which return Flow I'm wrapping and callback base api call using callbackFlow i Have my repository function which return Flow repository.kt fun getItem: Flow = callbackFlow { api.send( param, OnLoadDataCompleted { override fun onFinish(resultStr: String) { trySend(it) } } ) } I'm able to collect the above flow in my UI viewmodel.getItem.onEach { updateUI(it) } .flowOn(Dispatchers.IO) .launchIn(viewmodelScope) Question is how can I call...
  • u

    user

    07/17/2022, 10:01 AM
    Background suspend fire and forget channel processing in Kotlin + Spring What is the correct way to rake Channel in the background? Suppose I have long polling bot with onMessage(callbackSuspendAction: suspend.() -> Unit) and this callback is a heavy computation (20-30 seconds) I put these events to the messageHandlersQueue: Channel in the following way: messageHandlersQueue.send( coroutineScope { launch(start = CoroutineStart.LAZY) { val vkClient = VkClient(actor.userActor) processVkUserQuery(msg.chat.id, addressName,...
  • u

    user

    07/17/2022, 10:01 AM
    How to make a button like this? [Kotlin]

    enter image description here▾

    I want to make a button like this how can I do it? I want to change the color of shadow of the button.
  • u

    user

    07/17/2022, 10:21 AM
    How to learn material 3 component attribute use case Can someone help me on Material 3. I found this two method darkColorScheme and lightColorScheme . When I checked the definition of this function I found so many colors used in the function. I am confused which one using where so, Is there any documentation or blog where this type of attribute is using i.e. secondaryContainer, tertiary etc. this is few example I want to learn each attribute where this is using according to their name. I am new in material design with <a...
  • u

    user

    07/17/2022, 10:21 AM
    Regex ignoring matches between square brackets Hi I'm trying to create a Regex to help separate a string into a series of object fields, however having issues where the individual field values themselves are lists and therefore comma separated internally. string = "field1:1234,field2:[[1, 3],[3,4]], field3:[[1, 3],[3,4]]" I want the regex to identify only the commas before "field2" and "field3", ignoring the ones separating the list values (e.g. 1 and 3, ] and [, 3 and 4. I've tried using non-capturing groups to ignore the character after...
  • u

    user

    07/17/2022, 10:21 AM
    I am getting this error kotlin Android Problem 2022-07-17T12:12:26.242+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':app:kaptDebugKotlin'. A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction java.lang.reflect.InvocationTargetException (no error message) Try: Run with --scan to get full insights. Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:kaptDebugKotlin'. at...
  • u

    user

    07/17/2022, 10:41 AM
    Android Navigation Error: You must call setGraph() before calling getGraph() I'm trying to make an memo app, and this is my first time with application programming. When I tried to run the code on my device it just dies after showing the IntroActivity and the error log says: "You must call setGraph() before calling getGraph()" Below is the code. class ListActivity : AppCompatActivity() { private lateinit var appBarConfiguration: AppBarConfiguration private lateinit var binding: ActivityListBinding override fun onCreate(savedInstanceState: Bundle?) {...
  • u

    user

    07/17/2022, 11:01 AM
    Create over rides nothing package com.example.studentregister import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import com.example.studentregister.db.StudentDao import java.lang.IllegalArgumentException class StudentViewModelFactory( private val dao: StudentDao ):ViewModelProvider.Factory { override fun create(modelClass: Class): T { if(modelClass.isAssignableFrom(StudentViewModel::class.java)){ return StudentViewModel(dao) as T } throw...
  • u

    user

    07/17/2022, 11:21 AM
    Cannot use vibration in a Thread I'm trying to use the vibrator service inside a Thread class but when I do so, I have an error which says "Type mismatch: inferred type is String but Context was expected" here is my code : class myThread: Thread() { override fun run() { var vibration = getSystemService(Context.VIBRATOR_SERVICE) as Vibrator for(i in 1..5) { vibration.vibrate(100) Thread.sleep(1000) } } } It works in my mainActivity class but it doesn't in a Thread....
  • u

    user

    07/17/2022, 11:41 AM
    Platform class kotlin.Unit requires explicit JsonAdapter to be registered In a retrofit interface I have defined a method return type as ApiModel . but when I call the method I get the error below. Platform class kotlin.Unit requires explicit JsonAdapter to be registered so I tried to create my own JsonAdapter as below. class UnitJsonAdapter { @ToJson fun toJson(writer: JsonWriter) { writer.nullValue() } @FromJson fun fromJson(reader: JsonReader): Unit { reader.close() return Unit } } but I face this error....
  • u

    user

    07/17/2022, 12:01 PM
    Trying to display buffer from node backend to ImageView Kotlin I'm having issues trying to display buffer images to Kotlin, I don't know if I'm doing it wrong, I've tried everything, The return of the backend looks like this. I use node backend and mongo db database. Here is the output from backend I'm trying to display:...
  • u

    user

    07/17/2022, 12:21 PM
    Using Horizontal LazyRow with items in compose I am trying to figure out what would be the best approach to create this type of design: https://gyazo.com/bae04894f7ef079a06ad71f733026f33 https://gyazo.com/111eace0d8cdecdecad1c8a7b486faf7 Should I be using a Horizontal lazyRow as suggested with a scrollview or how would I go about doing this? Should I also...
Powered by Linen
Title
u

user

07/17/2022, 12:21 PM
Using Horizontal LazyRow with items in compose I am trying to figure out what would be the best approach to create this type of design: https://gyazo.com/bae04894f7ef079a06ad71f733026f33 https://gyazo.com/111eace0d8cdecdecad1c8a7b486faf7 Should I be using a Horizontal lazyRow as suggested with a scrollview or how would I go about doing this? Should I also...
View count: 5