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

    06/23/2022, 6:51 PM
    Put a marker of a person from firebase on a map I am developing an app and I cant figure out how to put a marker to the location of a person from my firebase. I have tried this: var ocherednyara: LatLng if(document.data.getValue("online") as Boolean){ ocherednyara = LatLng((document.data.getValue("latitude") as Double), (document.data.getValue("longitude") as Double)) placeMarkerOnMap(ocherednyara)...
  • u

    user

    06/23/2022, 8:11 PM
    MysqlDataTruncation Exception with Composite Primary Key in Spring Boot JPA I'm getting an SQL error when inserting data using Spring JPA and a composite primary key. Here is the relevant code: @Entity @IdClass(SeniorityHistoryId::class) @Table( indexes = [ Index(columnList = "category", name = "category_index") ], name = "seniority_history_table" ) class SeniorityHistory( @Column(columnDefinition = "date", nullable = false) @Convert(converter = YearMonthConverter::class) @Id val month: YearMonth, @Column(columnDefinition = "int unsigned",...
  • u

    user

    06/23/2022, 9:31 PM
    Not to consume the click everywhere on ClickableText I have some text with some parts clickable. What I have done is a composable that with a previously built annotated string displays the message that has some url sections: @Composable private fun MyClickableText( annotatedString: AnnotatedString, modifier: Modifier = Modifier, ) { ClickableText( text = annotatedString, onClick = { annotatedString.getStringAnnotations( tag = "URL", start = it, end = it...
  • u

    user

    06/23/2022, 9:31 PM
    Return from Try/Catch block in Kotlin Kotlin newbie here... So I have a method that returns a userDefined object fun doSomethingMagical(param1: String): UserDefinedObject { val result = UserDefinedObject // execute some code try { .... if(some expression){ val temp = //some code result = temp } return result } catch(e : Exception){ null } } the above method gives me 2 error: Variable 'result' must be initialized A 'return' expression required in a function...
  • u

    user

    06/23/2022, 9:51 PM
    How to customize ID value of the items displayed in RecyclerView? I have multiple items in RecyclerView element, and the IDs of those items are generated automatically. For some reason, I need to set specific id values instead of automatically generated ones. My question is it possible to set specific ID values on items in the RecyclerView element. Is it possible to set specific ID values on items in the RecyclerView element?
  • u

    user

    06/23/2022, 9:51 PM
    how to use firebase authentication (for google/facebook sign-in) in jetpack compose I know how to use the email password part of firebase. but I'm having a problem with finding any docs or code for the Login/Signup with google/facebook in jetpack compose.
  • u

    user

    06/23/2022, 10:11 PM
    How do games detect lost focus (such as opening notification pane) on Android For example in game Asphalt 9, when the player swiping down the notification, the game is paused. I have tried onPause, but it only fired when I switch to another app / activity. It doesn't detect something like opening the notification pane.
  • u

    user

    06/23/2022, 10:31 PM
    Send a ZIP file for a server using kotlin and retrofit I looking for a way to send a zip file for a server using retrofit in kotlin. Some functions are deprecated that's make this more dificulte. When I star the request the response is NULL, there is no error. That is the function who start the request: fun sendZipeFile() { val retrofitClient = NetworkUtils .getRetrofitInstance("http://url.com") val sendZipeFileEndPoint = retrofitClient.create(SendZipeFile::class.java) var file =...
  • u

    user

    06/23/2022, 11:51 PM
    get Incoming call contact name and phone number using android studio kotlin I'm trying to construct an app that requires the name and phone number of the incoming call contact. I did research to find a solution, but all the data I found was in java and there wasn't much in kotlin. Code found in Java : public class ServiceReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context, Intent intent) { TelephonyManager telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);...
  • u

    user

    06/24/2022, 12:51 AM
    Kotlin SAM `AbstractMethodError` Why does the SamTest2 interface throw an AbstractMethodError when accessing the other property? A default implementation is provided in the interface so I assumed the anonymous instance created in the main method would work properly. Is this an incorrect assumption? fun interface SamTest1 { fun method1(value: String): Boolean fun other(): String = "test" } fun interface SamTest2 { fun method1(value: String): Boolean val other: String get() = "test" } fun main() { val sam1...
  • u

    user

    06/24/2022, 1:51 AM
    Kotlin generic class with embedded instance of parameter class ZabbixAPIResult { var jsonrpc = "" var result = T() var id = "" } yields type parameter T cannot be called as a function Is it possible to declare something like this in Kotlin? I.e., a class that embeds an instance of a class supplied as a parameter?
  • u

    user

    06/24/2022, 1:51 AM
    Spring Data Rollback only rolls back partially While integration testing, I am attempting to test the execution of a stored procedure. To do so, I need to perform the following steps: Insert some setup data Execute the stored procedure Find the data in the downstream repo that is written to by the stored proc I am able to complete all of this successfully, however, after completion of the test only the rows written by the stored procedure are rolled back. Those rows inserted via the JdbcAggregateTemplate are not rolled back. Obviously I...
  • u

    user

    06/24/2022, 1:51 AM
    Error with Room dao class with Kotlin Coroutine

    Click here to see error logâ–¾

    Error error: Type of the parameter must be a class annotated with @Entity or a collection/array of it. kotlin.coroutines.Continuation
  • u

    user

    06/24/2022, 1:51 AM
    Android | Kotlin: How to make RecyclerView itemClick from Firebase Cloud Firestore? I want to make my RecyclerView item clickable, and after that show in DetailsActivity. I have made my code like this to show Toast and Log, but no data is showing. Is there something wrong with my code? Or is something missing? You see, I searched a lot on Google and YouTube that should use Firestore Adapter. Is that so? If yes, I don't know how to use this Firestore Adapter. This is code for OutletAdapter.kt class OutletAdapter(private val context: Context, private val outletList:...
  • u

    user

    06/24/2022, 4:31 AM
    Change Bottom Navigation Icon colour (or) icon , on tap of bottom Item view in compose The Question is regarding the Compose Bottom Navigation, I have created the bottom navigation view with NavHost I need to change the Icon state as (Enable/Disable) while clicking on it each time like changing the Icon or Icon colour itself
  • u

    user

    06/24/2022, 5:11 AM
    How to pass response data from api Fragment to adaptor for kotlin I have done some coding. But it's not helpful for me. I have made some fragments with tab layout with view pager & want to show response from api in one the fragment i have done all thing but i am totally stuck here I am totally confused here. Please help me. Thanx me in andvance
  • u

    user

    06/24/2022, 5:31 AM
    How to send notification every x minutes and not send when used set sleep schedule How to send notification every x minutes and not send when used set sleep schedule i am create reminder app send notification every 15,30 min what user select here is my code Alarm in my alarm reciver class i am check is current time is not sleep time show notification what is best way to achive this type of reminder app class AlarmReceiver : BroadcastReceiver() { private lateinit var notificationManager: NotificationManager private lateinit var notificationChannel: NotificationChannel...
  • u

    user

    06/24/2022, 5:31 AM
    Secondary constructor in Kotlin I have 2 secondary constructors for a data class. data class node(var type: String):parentNode(){ constructor(type: String, value: aNode) : this(type) constructor(type: String, value: bNode) : this(type) } I want to return a value from a function which is node(type:String, value:aNode). fun getNode(): node{ val aNode = getAnode val type = "Bank" val return_val = node(type,aNode) return (return_val)} a = getNode() Now 'a' has only the 'type' but not 'aNode'. Any idea on what am i...
  • u

    user

    06/24/2022, 6:28 AM
    How do I build a server for an Android app? How do I go about connecting my app to a server? I've literally no idea I have an application which is connected to firebase for Google sign in. Now I need to make a server to facilitate connection between people (kinda like messaging) My question is where do I write the code for backend? I have a bit of experience with Django so I reckon I can use Django for building the server but how can I go about connecting it to my application? Sorry if I'm not making sense. Guidance is appreciated....
  • u

    user

    06/24/2022, 6:51 AM
    jOOQ upsert a pojo Feeling a bit stupid, but I have a simple architecture where the repositories are the only ones accessing ~Record classes and the services work on POJOs. So basic flow is repository fetches into POJO service modifies POJO repository receives POJO to update DB repository matches updated POJO to record repository stores (insert or update) the record repository maps updated record (may have received generated values from insert) back to POJO service receives updated POJO i.e. something like fun...
  • u

    user

    06/24/2022, 8:11 AM
    resolve build failure in android studio - while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkActio I am new to the team, and freshly set up the project in android studio. I am the only one getting this error. This is the headline of the error A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction Here is the stack trace: FAILURE: Build completed with 2 failures. 1: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':appmanager:kaptProdDebugKotlin'.
    A failure occurred while executing...
  • u

    user

    06/24/2022, 8:11 AM
    How to allow sidebar persistence in my android app? The smartbar (from settings > Convience tools) is quite useful. The problem is that when I open my application I want the smart bar to be callable but I've no idea what to change in my app to make it possible. Help?

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

  • u

    user

    06/24/2022, 8:31 AM
    Conflict in attribute name between 3rd party dependency I am developing Android application where there are multiple 3rd party dependency are included. Now scenario is like, there are 2 different 3rd party library both having same attribute name in their attrs.xml during compile, it's giving error for same.
  • u

    user

    06/24/2022, 8:31 AM
    Layout behind edit text's select handler hides ui beneath it

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

    When user clicks on edit text the cursor has a layout beneath. I have made the text_select_handler transparent but couldn't remove this layout beneath it. Any kind of help is appreciated. Thanks in advance.
  • u

    user

    06/24/2022, 8:31 AM
    How to correctly pass a parameter to a lambda in onClick using Jetpack Compose I am trying to call a composable which has a parameter This is the composable I want to call onClick @Composable fun ShowCustomChromeTab(articleUrl: String){ .......//it has a parameter } Now when user clicks on an item: @Composable fun ArticleItem(article: Article, onClick: () -> Unit){ Box( modifier = Modifier .clickable { onClick(article.url) }, ) This is how I am now using it var shouldOpenChromeTab by rememberSaveable { mutableStateOf(false) } var...
  • u

    user

    06/24/2022, 9:11 AM
    Split character from string in Idiomatic way Kotlin Hey I am working in kotlin. I have one string in which I want to split into list from there where I should provide character. I'll explain in details For example 1 val string = "Birth Control" val searchText = "n" Output ["Birth Co", "trol"] For example 2 val string = "Bladder Infection" val searchText = "i" Actual Output ["Bladder ", "nfect", "on"] Expect Output ["Bladder ", "nfect", "ion"] I tried some code but example 1 is working fine but example 2 is not because I only want to...
  • u

    user

    06/24/2022, 9:11 AM
    @Value annotation not working with springboot 2.3.1 I have this test class with some test cases class TestClass(@Value("\${s3.published.bucket}") private val publishedBucketName: String) { } I have 2.1.8.Release currently for springBoot version and everything works fine, all tests are passing now i need to migrate to springboot 2.3.1.Release But it seems that @Value annotation is not able to pick value s3.published.bucket from my application.yml in src/main. Application.yml s3: region: ${s3_region:eu-central-1} published: bucket:...
  • u

    user

    06/24/2022, 9:31 AM
    Returning a new array created from adding odd numbers from an array I am trying to create an array from this following array arr=[1,2,3,4,5,6,7,8,9] and it will return as sum of numbers in this way 1+3 =4 ,3+5=8,5+7=12,7+9=16. so that final answer would be newArray =[4,8,12,16]. How can I achieve it. I have done below code but it doesn't work . fun main(){ val sum = arrayOf(1,2,3,4,5,6,7,8,9) var first =0; var second=0 for (i in sum.indices){ if(sum[i]%2!=0){ first += sum[i] if (second!=0){...
  • u

    user

    06/24/2022, 9:51 AM
    Outputstream still saves old data I have an application in which I can receive bluetooth messages, but whenever I write a message it will still remember data from the previous message. How do I clear this? Underneath is my code for sending the message: private fun sendMessage(message: String) { messages.add(message) val time = SimpleDateFormat("HH🇲🇲ss").format(Date()) messageAdapter?.add( "$message\n\t${bluetoothAdapter?.name} $time" )...
  • u

    user

    06/24/2022, 9:51 AM
    Trying to pass a string from an activity to a fragment when login is successful (Kotlin) I'm developing an android app with Kotlin and I need some help. So I made a login and register in firebase, and in the register activity (contains both the register and login) created a method to open the main menu and pass a string to a fragment if the login or register is successful. If the user authenticates correctly it does bring them to the main menu, so that part works. But when I try to pass a string in a bundle to my fragment and showing it in its text view it doesn't work. There are...
Powered by Linen
Title
u

user

06/24/2022, 9:51 AM
Trying to pass a string from an activity to a fragment when login is successful (Kotlin) I'm developing an android app with Kotlin and I need some help. So I made a login and register in firebase, and in the register activity (contains both the register and login) created a method to open the main menu and pass a string to a fragment if the login or register is successful. If the user authenticates correctly it does bring them to the main menu, so that part works. But when I try to pass a string in a bundle to my fragment and showing it in its text view it doesn't work. There are...
View count: 9