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/09/2022, 7:31 PM
    JOOQ 3.17.2 - Attempt to execute a blocking method when only an R2BDC ConnectionFactory was configured Dependencies used: implementation("org.jooq:jooq:3.17.2") implementation("org.jooq:jooq-meta:3.17.2") implementation("org.jooq:jooq-kotlin-coroutines:3.17.2") implementation("org.jooq:jooq-kotlin:3.17.2") runtimeOnly("io.r2dbc:r2dbc-spi") { version { strictly("0.9.1.RELEASE") } } runtimeOnly("dev.miku:r2dbc-mysql:0.8.2.RELEASE") runtimeOnly("io.r2dbc:r2dbc-pool:0.9.1.RELEASE") // Kotlin 1.6.20...
  • u

    user

    07/09/2022, 7:31 PM
    Its every project android native (kotlin) should use jetpack compose ? or its fine to use xml? Its every project android native (kotlin) should use jetpack compose ? or its fine to use xml ?
  • u

    user

    07/09/2022, 7:31 PM
    Could not find org.kodein.di:kodein-di-generic-jvm:7.3.1 i work with kodein dependency injection but after update the depenedency version 6.4.0 to 7.3.1 it show this error Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find org.kodein.di:kodein-di-generic-jvm:7.3.1. i try to move version to old version but kodein didn't work in kotlin code with old version kodein dependency : implementation 'org.kodein.di:kodein-di-generic-jvm:7.3.1' implementation "org.kodein.di:kodein-di-framework-android-x:7.13.0"`
  • u

    user

    07/09/2022, 8:11 PM
    How to get device location when a BTLE event triggers in broadcast receiver? I am statically registering Broadcast Receiver for BTLE connection/disconnection events to detect when my bluetooth headphones connects/disconnects with my Android phone. I also want to record the current location of my phone to update to a server when the OnReceive event for bluetooth is triggered. I am using FusedLocationProviderClient to get current location with fine, coarse and background location permissions declared in the manifest, but the location received is always null. How do I...
  • u

    user

    07/09/2022, 9:11 PM
    Forground service notification get replaced by another notification I have two forground service FS1 and FS2 , with each one i create notification , if FS1 is running and i start FS2 the old notification get replaced , i want both to stay , this is how i create notification private fun createNotification(): Notification { val notificationChannelId = "123" if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val channel...
  • u

    user

    07/09/2022, 9:51 PM
    i tried to override the ServiceConnection interfcae method but i got this error ComponentName ,IBinder and Intent not resolved I tried to handle the below task in kotlin android I have an application with a button that show the time when it is clicked , The time will gotten from a bound service and will be shown on Textview on Activity when I run the application i got the below error however it is alreday defined in the import e: D:\boundService\app\src\main\java\com\example\boundservice\MainActivity.kt: (24, 52): Unresolved reference: ComponentName e:...
  • u

    user

    07/09/2022, 9:51 PM
    Cannot construct instance of `{dataclass}, problem: Should never call `set()` on setterless property "authors" is my collection in MongoDB. my schema authors = [ { name: "Author1", books: [ {title:"Book1"}, {title:"Book2"} ] } ] I'm trying to append the books array by adding another book object (book3). Before that, I have to check whether there exists an object already in the author's name. So I have the findOneByAuthorname function. My issue is that every time I try to call the findOneByAuthorname function. I get an error - Unhandled: POST - /v1/api/addBooks. Exception class...
  • u

    user

    07/09/2022, 10:11 PM
    Cropping Image from Map Android Kotlin I have a Google Map in my Android Kotlin App. I want to do something as follows : The User should be able to cut out a rectangular portion from the map This rectangular portion should be send as an image to an API (Here the API accepts requests in the form of image in multipart data) The location of the cut-out area should also be send as a response to the API. Any suggestions on how to do this? Thanks in advance!
  • u

    user

    07/09/2022, 10:51 PM
    Osmdroid marker slow to draw after click to map I'm brand new to Open Street Map and have successfully added a map to my activity at the user's location and implemented an onClickListener that upon a click shows a marker and retrieves the latitude and longitude of that point. Here is my code private fun showMap(dLatInit: Double, dLonInit: Double){ mapView.setTileSource(TileSourceFactory.MAPNIK) Configuration.getInstance().userAgentValue =packageName mapView.setMultiTouchControls(true) mapController = mapView.controller as...
  • u

    user

    07/10/2022, 1:11 AM
    Wait for channel close I have a channel that I only use to convey that a connection was closed. I figured a Unit channel which I then close on disconnect would be the most appropriate. Simplified example: class Connection { val disconnect = Channel(1, BufferOverflow.DROP_LATEST) fun connect() { backingConnection.disconnectCallback = { disconnect.close() } backingConnection.connect() } } Now the question is how to wait for this channel to close. Here are two options, both look a bit...
  • u

    user

    07/10/2022, 2:11 AM
    aws sns push notification Creating a platform endpoint from Kotlin I am using AWS SNS for push notification using FCM. Push notification Implementation is working fine. Is there any tutorial on how to create platform endpoint from kotlin mobile side?. Or is it supposed to do it from server side?
  • u

    user

    07/10/2022, 2:31 AM
    AnimatedVisibility does not work in Compose My code: class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { var visibile by remember { mutableStateOf(false) } Column(modifier = Modifier.fillMaxSize()) { Text(text = if (visibile) "visible" else "hide", modifier = Modifier.clickable { visibile = !visibile }) if (visibile) {...
  • u

    user

    07/10/2022, 4:31 AM
    How to make a button in Dialog close that Dialog (Kotlin) I have a custom dialog that's initialized in onCreate() of some Activity. It displays some text and a button. I want the button to close the dialog when clicked. How can I achieve this? Here's my attempt that fails. MyActivity.kt class MyActivity : AppCompatActivity() { private lateinit var myDialog: Dialog override fun onCreate(savedInstanceState: Bundle?) { ... myDialog = Dialog(this) myDialog.setContentView(R.layout.my_dialog_layout) val button =...
  • u

    user

    07/10/2022, 5:51 AM
    What is the menuInflater in Android Studio? I've been studying Kotlin and Android development, and studying the code samples in Android Studio, I've encountered this block: override fun onCreateOptionsMenu(menu: Menu): Boolean { // Inflate the menu; this adds items to the action bar if it is present. menuInflater.inflate(R.menu.menu_main, menu) return true } I know that first you have to instantiate a variable for the inflater to use the inflate() method, but there is no menuInflater variable in this...
  • u

    user

    07/10/2022, 5:51 AM
    How do I get a small movable pop up window like this I am wondering how I create a small pop up window like my image. It is Samsungs timer window. I am wondering what it is. Is it an activity, fragment, something else? Any idea how I would do it? I still want to see whatever was on the screen at the time, just with the popup.

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

  • u

    user

    07/10/2022, 7:11 AM
    Kotlin - EditText in Inflated View keyboard show on back with black opacity I inflated popup view with below code but the problem is keyboard is shown backof popup val inflater = it.context?.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater? val menuPopup = inflater!!.inflate(R.layout.popup_search_new_cosmetics,null) val popup = PopupWindow(menuPopup, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, false) popup.showAtLocation(menuPopup, Gravity.CENTER,0,0)...
  • u

    user

    07/10/2022, 7:51 AM
    What resources should I look into to make an app that disables other apps similar to digital wellbeing? I'd like to make an app that helps with limiting screentime/concentration. I know of disabling them with the PackageManager, but I'd like to do it the way Digital Wellbeing can disable apps based on time used, and re-enable the next day. How should I approach this efficiently and what could help me with this? Constantly checking for time and then updating it sounds inefficient. Also I don't want users to have to reinstall the app, and that's usually required when an app is disabled. Or (only...
  • u

    user

    07/10/2022, 7:51 AM
    403 From Google Drive API When Using API Key I've got a Kotlin application that retrieves publicly availably PDFs stored on Google drive. To download the PDFs, I do the following @Throws(IOException::class) fun download(url: String?, destination: File?) { val connection: URLConnection = URL(url).openConnection() connection.setConnectTimeout(60000) connection.setReadTimeout(60000) connection.addRequestProperty("User-Agent", "Mozilla/5.0") val output = FileOutputStream(destination, false) val buffer =...
  • u

    user

    07/10/2022, 8:11 AM
    Kotlin, Inflated EditText, when keyboard shows, view is crumbled when keyboard is up, inflated view show weird. what may be the problem ? val inflater = it.context?.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater? val menuPopup = inflater!!.inflate(R.layout.popup_search_new_cosmetics,null) val popup = PopupWindow(menuPopup, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true) popup.showAtLocation(menuPopup, Gravity.CENTER,0,0) val imgClose =...
  • u

    user

    07/10/2022, 8:31 AM
    Java superclass and subclass generics in Kotlin I'm looking for documentation or specifications about Java generics in Kotlin. I'm curious about the behavior that is different between the superclass and the subclass. For example, here is the following Java code. // A.java public class A { public T value; public A(T value) { this.value = value; } } // B.java public class B extends A { public B(T value) { super(value); } } Use the above Java code from Kotlin. fun main() { val a = A("a") val b =...
  • u

    user

    07/10/2022, 8:31 AM
    The binary version of its metadata is 1.7.1, expected version is 1.5.1 C:/Users/khare/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.7.0/51736992f422993a1e741051bdf3c12801bc1ca1/kotlin-stdlib-common-1.7.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1. What should I do ? How to fix it ?
  • u

    user

    07/10/2022, 8:51 AM
    I am trying to save model class data in DB using Spring with Kotlin but I am getting exception I am learning Spring with Kotlin and I am getting below exceptions while saving data in the local Database My Rest Controller looks like below @RestController class MarketPlaceController(val service: MessageService) { @GetMapping("/homepage") fun getHomePage() = "NFTs Marketplace" @GetMapping("/errorpage") fun getErrorPage() = "This is error" private var NFTs = mutableListOf( Message(1, "Title #1", "Description #1"), Message(2, "Sneaky Vampire Syndicate", "Description #2"),...
  • u

    user

    07/10/2022, 9:51 AM
    Recycler view not update itself I have a problem with recycler view. In my previous app, when i get the list for recycler view adapter from database and observe it in my fragment, i used the notifyDataSetChanged() and when i tried to delete a item , view updated successfully. But in this app this does not work and i don't understand why. When i click the delete button the item deleted in database successfully but i can't see it immediatly. When i go to any other fragment and back to this Favourites fragment i see the items...
  • u

    user

    07/10/2022, 9:51 AM
    Spring Boot file upload doesn't work (bad request) I'm trying to do a simple file upload via a Rest API created with Spring Boot and Kotlin. This is my code: @RestController @RequestMapping("/api") class Controller { @PostMapping("/upload") fun handleFileUpload(@RequestParam("file") file: MultipartFile): ResponseEntity { try { file.transferTo(File("C:\\upload\\" + file.originalFilename)) } catch (e: Exception) { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build()...
  • u

    user

    07/10/2022, 10:31 AM
    Unresolved reference: "StartActivity" [KOTLIN] I'm trying to open multiple links with one webview activity, from MainActivity using bottomsheet dialog to my WebView activity, but i have problem with : Unresolved reference: StartActivity class MainActivity : AppCompatActivity() { private var urls = arrayOfNulls(2) @SuppressLint("WrongConstant") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) urls[0] =...
  • u

    user

    07/10/2022, 11:11 AM
    How to show a overlay at a Recyclerview in Android? (see video) How can I achieve the following result in Android? Instead of trying to explain the behaviour in text, I think it's the easiest if I show you the behaviour, so I recorded a video of a prototype: Video can be seen here: https://www.loom.com/share/a928378f4e9646f4946e9d837d792221 Note: The list of items is a RecyclerView
  • u

    user

    07/10/2022, 12:11 PM
    Using swipeFreshLayout on Fragment I have swipeRefreshLayout on fragment on displaydata, however it does not perform the refresh function. The refresh symbol appears and then disappears as it should, but it doesn't actually refresh the pull to the api. Home/Fragment.kt package com.example.what2do_v6.ui.home import android.annotation.SuppressLint import android.os.Bundle import android.util.Log import android.view.View import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager import...
  • u

    user

    07/10/2022, 12:11 PM
    Using a flow builder and asFlow error that should call from suspend function I have the following interface to fetch recipes interface FoodService { @GET(EndPoint.COMPLEX_SEARCH) suspend fun fetchComplexSearch(@Query("apiKey") apiKey: String): ResultModel } This works find using a flow builder override fun complexSearch(apiKey: String): Flow { return flow { val resultModel = foodService.fetchComplexSearch(apiKey) val listOfComplexSearchEntity = resultModel.results.map { complexSearchModel ->...
  • u

    user

    07/10/2022, 12:11 PM
    Flow is not collected in Composable Im creating a Flow inside my repository which fetches data from an sse api override fun getStrean() = flow { try { val response = api.getStream() while (true) { //do something with response emit(result) } } catch (e: HttpException) { .. } } It get forwarded into my composable where the viewmodel gets injected @Composable fun PageWohnzimmer( viewmodel: myviewmodel = hiltViewModel() ) The flow then gets collected like...
  • u

    user

    07/10/2022, 12:31 PM
    How to add OnClickListener with databinding in recycleView buttons? I am fetching the categories from an API and I would like to fire up a new fragment by passing the category name to retrofit on the button click. I am thinking of doing it in my UI with getText() on the button clicked and firing up the API call which will display the result on a new fragment. The API I am using is https://fakestoreapi.com/ To my understanding, I have to handle the click events in the UI part (Fragment's Code). The code below is in my FakeApiService.kt @GET("categories")...
Powered by Linen
Title
u

user

07/10/2022, 12:31 PM
How to add OnClickListener with databinding in recycleView buttons? I am fetching the categories from an API and I would like to fire up a new fragment by passing the category name to retrofit on the button click. I am thinking of doing it in my UI with getText() on the button clicked and firing up the API call which will display the result on a new fragment. The API I am using is https://fakestoreapi.com/ To my understanding, I have to handle the click events in the UI part (Fragment's Code). The code below is in my FakeApiService.kt @GET("categories")...
View count: 5