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/22/2022, 6:01 PM
    DataBinding enable button Android If text ok for my condition enable button, else disable. This Code not work android:text="@={insertCredential.username}" android:enabled="@{insertCredential.rememberMe}" class InsertCredentialObserver : BaseObservable() { private var username: String = "" private var rememberMe = false @Bindable fun getUsername(): String { return username } fun setUsername(username: String?) { this.username = username!! notifyPropertyChanged(BR.username) if...
  • u

    user

    07/22/2022, 6:41 PM
    Kotlin Generics: Lifecycle-level storage for multiple instances of Class&lt;T&gt; where T is different for each instance Im trying to make an abstract FormFragment to reuse for all my forms in future proyects. Almost everything about the generics are ok as class level parameters goes. But im trying to implement the following idea: I want that my Abstract fragment implements a class-level attribute that stores 1...N "BaseAdapter< T >" where T is my entity wich may (will) vary for each BaseAdapter. I'm done implementing this with only one BaseAdapter< T > because i can straight fordward use the main < T > i sent...
  • u

    user

    07/22/2022, 6:41 PM
    How to navigate from specific selected item RecyclerView Inside the Fragment, to 2 different Activity from same RecyclerView in Kotlin? How to navigate from specific selested item RecyclerView Inside the Fragment, to 2 different Activity in Kotlin?

    https://i.stack.imgur.com/WqUiv.jpgโ–พ

    i have the basic wireframe layout, who describe my question, because i don't know how to explain with good typing. so here from the wireframe, i have 1 Activity with TabLayout, which is filled with Fragment and there is a RecyclerView in it. And then I have 2 more different Activities. for now, i've...
  • u

    user

    07/22/2022, 7:01 PM
    Spring webflux flux.fromiterable Can someone help me on this. I have a list of entities and I have to call rest call for each of the entities. I have used flux.fromiterable for the same. But the control is not even coming to the rest client.
  • u

    user

    07/22/2022, 7:01 PM
    Android: onClickListener fires a observer to update field on UI, again and again I have a question. This is my situation. I have a UI to update values on an Data Object (room data). Let's say that is a radio Button, but could be anything. I want that every time the user click on a field (radio button, text, checkbox) the database get updated, I don't want a "save" button. To achieve this, I have a bunch of onClicklistener() on each view element. These listeners call some method on the viewmodel instance, that updated the MutableLiveData of that class, firing, the observer...
  • u

    user

    07/22/2022, 7:21 PM
    How to implement Banner Ad in Android Studio Kotlin? I followed the instructions in the google documentation but it doesn't work, the app closes when trying to open the activity where the ad would be, the whole app is made with recyclerview, the error is: java.lang.NullPointerException: findViewById(R.id.adViewComoSeJuega) must not be null This is my Activity: class ComoSeJuegaActivity : AppCompatActivity() { lateinit var mAdView : AdView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState)...
  • u

    user

    07/22/2022, 7:21 PM
    android.database.sqlite.SQLiteException unknown error (code 0 SQLITE_OK): Native could not read blob slot I see the following error message on BugSnag only for the users who has a massive amount of data persisted on the sqldelight database android.database.sqlite.SQLiteException ยท unknown error (code 0 SQLITE_OK): Native could not read blob slot CursorWindow.java:-2 android.database.CursorWindow.nativeGetBlob CursorWindow.java:434 android.database.CursorWindow.getBlob AbstractWindowedCursor.java:47...
  • u

    user

    07/22/2022, 9:41 PM
    Can we print each statement for every 1 second or 5 seconds or any number of seconds in kotlin I want to print the following code which prints the numbers from 1 to 10 to be printed one by one with a time gap. I'm a beginner in Kotlin, so is there any method/or a function to do this?. If not what type of logic is required to achieve this?. fun main(){ var countNumbers= mutableListOf("1","2","3","4","5","6","7","8","9","10") for(i in countNumbers) { println(i) } }
  • u

    user

    07/22/2022, 10:01 PM
    Composite-id class must implement Serializable: io.digiwave.entities.StoreEntity I try to use Hibernate in Quarkus with Kotlin. The entity definition looks as follows: @Entity open class StoreEntity( ) : PanacheEntity() { @EmbeddedId lateinit var userId: UserId lateinit var password: String var createdAt: Long = 0 } and the composite key: @Embeddable open class UserId( ) : Serializable { lateinit var id: String } Unfortunately the compiler complains: Caused by: org.hibernate.MappingException: Composite-id class must implement Serializable:...
  • u

    user

    07/22/2022, 10:01 PM
    TextViews never update Here's the gist: I'm a beginner, and am trying to create an app where you input a number and if that number matches a randomly generated number you "win". My issue is that I have 2 textviews towards the bottom of the screen and their values never update. One (tVWinORLose) for displaying a simple "You Win/Lose", and one (tVFinalOutput) for outputting your guess and the randomly generated number. After I click the "Press to Guess" button, they both remain blank. Assistance would be greatly...
  • u

    user

    07/22/2022, 10:41 PM
    How would I update a single item in an ArrayList of items with data from Room? (android Kotlin) I am fetching a list of dogs from an endpoint. Some of the attributes of the dog, color for example, are identified by id. The id's and colors corresponding to the id were all saved in a database when the app is opened. I am using MVVM architecture and assume that the model is consuming the response data correctly. In the main screen of the app, I have a recyclerView that will populate with a list of dogs. when I fetch the list of dogs, I am returned the id of the dog's color as part of the...
  • u

    user

    07/22/2022, 10:41 PM
    How can i parse JSON object with multiple arrays? fun main(args: Array) { val client = HttpClient.newBuilder().build() val request = HttpRequest.newBuilder() .uri(URI.create("https://api.track24.ru/tracking.json.php?apiKey=$api&amp;domain=Artur&amp;pretty=true&amp;code=$trackCode")) .build() val response = client.send(request, HttpResponse.BodyHandlers.ofString()) println(response.body()) @JsonIgnoreProperties(ignoreUnknown = true) data class jsonToKotlin( val status: String?, val data: HashMap ) //val mapper = jacksonObjectMapper()...
  • u

    user

    07/22/2022, 11:41 PM
    Why is my kotlin hash set not adding elements I am new to kotlin and I want to make an abstract/open class or interface, something that can be implemented by other classes. Let's call it Test. Now Test needs to have a HashSet (the docs say it requires less memory than a normal set) that every derived class will implement and fill with its own values. interface Test { val players: HashSet } class Supa: Test { override val players = hashSetOf() fun later() { players.add("new player") } } fun main() {...
  • u

    user

    07/23/2022, 1:01 AM
    @Composable invocations can only happen from the context of a @Composable function(Google SignIn) @Composable fun loginButton(loginType: Int, context: Context, googleSignInClient: GoogleSignInClient?) { Column(horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.fillMaxWidth()) { if (loginType == 0) { OutlinedButton(onClick = { googleSignIn(context = context, googleSignInClient = googleSignInClient) }, border = BorderStroke(2.dp, Color.Black), colors = ButtonDefaults.buttonColors(backgroundColor = Color(0xFFFFFFFF)),...
  • u

    user

    07/23/2022, 1:41 AM
    Where is annotation stored in ir tree for backing field? Where is annotation stored in ir tree? is it in backing field descriptor? I have @Deprecated("") val DEPRECATED_STATIC_FIELD = "deprecated field" ir tree is below PROPERTY name:DEPRECATED_STATIC_FIELD visibility:public modality:FINAL [val] annotations: Deprecated(message = '', replaceWith = , level = ) FIELD PROPERTY_BACKING_FIELD name:DEPRECATED_STATIC_FIELD type:kotlin.String visibility:private [final,static] EXPRESSION_BODY CONST String type=kotlin.String...
  • u

    user

    07/23/2022, 2:01 AM
    Broadcast IR signals using API level 16 (android 4.1) in android studio i am trying to develop an app that uses the IR blaster on an old phone to mimic a

    standard 24 key RGB remoteโ–พ

    i found the

    IR signal codesโ–พ

    but support for IR was only added in API level 19. is there a way for me to make an IR app on a phone that only supports android 4.1 (LG Optimus F6 T-Mobile version)
  • u

    user

    07/23/2022, 3:21 AM
    why is the wrong activity launched in Android App? I assume, there ist something wrong with my AndroidManifest.xml. The relevent part is with MainActivity.kt beeing class MainActivity : AppCompatActivity() { private lateinit var text123: TextView private lateinit var YOBtn: Button override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState)...
  • u

    user

    07/23/2022, 3:21 AM
    Kotlin constructor val vs private val If I have something like the following: interface IRecordService { fun doSomething () : Record } @MongoRepository interface IRecordRepository : MongoRepository { } @Service class RecordService ( private val recordRepository : IRecordRepository // or just val instead of private val ) : IRecordService { override fun doSomething () : Record { // does something } } Is there any difference between using private val in the RecordService constructor vs just val? I've seen...
  • u

    user

    07/23/2022, 4:01 AM
    android.app.contextimpl cannot be cast to android.content.contextwrapper I created a SDK for sms syncing import android.content.Context import android.content.ContextWrapper import android.app.Application import android.view.View import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.Observer import androidx.work.* fun Context.lifecycleOwner(): LifecycleOwner? { var curContext = this var maxDepth = 20 while (maxDepth-- > 0 && curContext !is LifecycleOwner) { curContext = (curContext as ContextWrapper).baseContext } return...
  • u

    user

    07/23/2022, 4:01 AM
    Android Studio Import module unity library : Specify location of gradle or android eclipse project I'm trying to add a new module to import an aar package of a unity library by providing the following path : G:\sample\UnityLibrary\unityLibrary\build\outputs\aar\unityLibraryDebug.aar But I'm getting this message every time I type the path : Specify location of Gradle or Android Eclipse Project
  • u

    user

    07/23/2022, 4:21 AM
    How to perform firebase authentication that returns a flow in android kotlin What I currently have: I have a service class where I perform firebase registration for a user. It is working. What I am trying to do: I am trying to return a flow Current code: class LoginService @Inject constructor( // This contains the firebase auth reference val service : FirebaseAuthRepository ) { private fun registerUser( firstName:String, lastName:String, email:String, password:String ) { // Create an instance and create a register a user with...
  • u

    user

    07/23/2022, 4:41 AM
    TransactionTooLargeException: data parcel size 896372 bytes mBinding.attachBtn.setOnClickListener { mGetContent.launch("image/*") } This is the launch code mGetContent = registerForActivityResult(ActivityResultContracts.GetContent(), ActivityResultCallback { val intent = Intent(APP_ACTIVITY, CropperAcrtivity::class.java) intent.putExtra("DATA", it.toString()) startActivityForResult(intent, 101) }) Initializing mGetContent override fun onActivityResult(requestCode: Int, resultCode: Int,...
  • u

    user

    07/23/2022, 5:01 AM
    Cloning object of subclass type in Kotlin I wanted to be able to define a method to clone an object that is the same type of itself. I define the interface requesting such, but the following does not compile or run. interface Foo { fun copy() : T } class Bar(private val v:Int) : Foo { override fun copy():Bar = Bar(v) } main() { val bar1 = Bar(1) val bar2 = bar1.copy() } If however I write the implementing class in Java, it will compile class Bar implements Foo { private int v; public Bar(int v) {this.v = v;} public...
  • u

    user

    07/23/2022, 6:01 AM
    what's the difference between The Method reference and lambda expression in kotlin? I'm testing the difference between method ref and lambda. I tried using both, and found the difference in decompiled code. that was like below. public final class TestKt { public static final void main() { final Print printTest = new Print(); text((Function0)(new Function0() { // $FF: synthetic method // $FF: bridge method public Object invoke() { this.invoke(); return Unit.INSTANCE; } public final void...
  • u

    user

    07/23/2022, 6:01 AM
    how to enable @Preview for kotlin desktop compose demo project? I downloaded the demo project to study kotlin compose. I try to add @Preview on a @Composable fun, but get warn that: Unresolved reference: Preview I add implementation("androidx.compose.ui:ui-tooling-preview:1.1.1") in kotlin.sourceSets.named("CommonMain").dependencies in <a href="https://github.com/JetBrains/compose-jb/blob/master/examples/codeviewer/build.gradle.kts"...
  • u

    user

    07/23/2022, 6:21 AM
    Efficient rendering of many Jetbrains Compose elements at absolute coordinates within a graphics layer I am trying to render a large number of "nodes" in a freeform sandbox area with Jetbrains Compose. Each node has it's own X,Y position. The editor is in a graphicsLayer where it can be panned and scaled. Inside this sandbox area, each node is offset by it's X,Y values and then rendered. However, the graphicsLayer has it's own size, and when translated/panned far enough that it goes off screen, all "nodes" disappear since Compose thinks that the bounding box of the graphics layer is no longer...
  • u

    user

    07/23/2022, 6:41 AM
    Why does Gradle force a Kotlin version, and how to fix it? I have a simple Gradle project that includes the following configuration: plugins { kotlin("jvm") } This does different things when running with different gradle versions: $ ./gradlew wrapper --gradle-version=7.5 $ ./gradlew --version Kotlin: 1.6.21 $ ./gradlew wrapper --gradle-version=7.4.2 $ ./gradlew --version Kotlin: 1.5.31 $ ./gradlew wrapper --gradle-version=7.2 $ ./gradlew --version Kotlin: 1.5.21 OK, so Gradle is determining the version of the Kotlin plugin....
  • u

    user

    07/23/2022, 7:01 AM
    This suspend function is taking very long time to execute ,How can I optimize this? I am writing code to get newsfeed from database and to show this feed in UI . This is my Firestore database structure users->uniqueUserId |-->UsersProfileInfo--->Profile(document) |-->FeedNewsFeed |--->unique documents for each newsfeed |--->unique documents for each newsfeed |--->unique documents for each newsfeed to get each news feed from every users in my user collection I have to write nested...
  • u

    user

    07/23/2022, 7:21 AM
    kotlin language not working with use of command prompt and notepad I installed Kotlin command line compiler wrote following program as '.kt' and saved it as hi1.kt 'fun main(args:Array) { println("Hi") }' i tried to compile it by usual way in cmd with kotlinc hi1.kt -include-runtime -d hi1.jar shows warning as parameter 'args' never used and if i try to run program by java jar hi1.jar shows Error:could not find or load main class jar Caused by:java.lang.ClassNotFoundException : jar can any body help me with situation what should i do Note:-I have set...
  • u

    user

    07/23/2022, 7:21 AM
    how can we use perform gestures feature in android with accessibility permission java I was just curious how can we use the perform gesture feature in android as we get a warning prompted whenever we add accessibility permission in an app
Powered by Linen
Title
u

user

07/23/2022, 7:21 AM
how can we use perform gestures feature in android with accessibility permission java I was just curious how can we use the perform gesture feature in android as we get a warning prompted whenever we add accessibility permission in an app
View count: 9