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/10/2022, 1:11 PM
    Material 3 NavigationBarItem how to change selected and unselected icons Can the image of a NavigationBarItem icon be changed whenever the NavigationBarItem is selected or unselected? Current result

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

    Expected result

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

    sealed class BottomNavItem(var title: String, var icon: ImageVector, var screen_route: String){ object Users: BottomNavItem("Users", Icons.Filled.AccountBox,"users") object Notifications:...
  • u

    user

    07/10/2022, 1:11 PM
    How to check if a composable is on top of the back stack or not? I have a navigation graph containing a HomeScreen and a MyBottomSheet. For bottom sheets I am using Accompanist Navigation. Both of the destinations share a common ViewModel which is scoped to that navigation graph. From that ViewModel I am exposing a Flow where MyEvent is: sealed interface MyEvent object MyEvent1: MyEvent object MyEvent2: MyEvent The two composables look like this: @Composable fun HomeScreen(viewModel: MyViewModel) { LaunchedEffect(Unit) {...
  • u

    user

    07/10/2022, 1:51 PM
    How to fix 'ARGUMENTS_NOT_ALLOWED' error Realm SDK for Kotlin? I am using MongoDB to save data from my Android app which I am developing with Kotlin Jetpack Compose. I am using MongoClient to access the database and save the data, but when I try to insert a Document I get this error: Error: ARGUMENTS_NOT_ALLOWED(realm::app::ServiceError:13) This is my code where I login and try to insert a Document into MongoDB Cluster: Realm.init(this) val appID : String = "my-app-id"; app = App( AppConfiguration.Builder(appID) .build())...
  • u

    user

    07/10/2022, 1:51 PM
    @OneToMany field is wrongly included in JPA query I have a small project to tinker with Spring, where I have two entities with a one to many association: 1 Restaurant -> N Dishes. I have the following PostgreSQL schema for that: create table if not exists restaurants ( restaurant_id uuid primary key, name varchar(512) not null, description varchar(1024) not null, address varchar(512) not null, photo_url varchar(1024) ); create table if not exists dishes ( dish_id uuid primary key, name varchar(512) not null,...
  • u

    user

    07/10/2022, 2:11 PM
    Android Studio Kotlin how to make a Constraint Layout scrollable with Scroll View? Basically I want to make the screen scrollable when the keyboard appears during text input, but no matter what I do it refuses to work. I made a Scroll View and put a Constraint Layout with all the elements in it. But it just refuses to scroll when the keyboard pops up. This is the .xml and this is how the activity looks like <a...
  • u

    user

    07/10/2022, 2:11 PM
    Generic producer and consumer without exposing concrete types in Kotlin I've been reading up on Kotlin generics for a while and came to a sense that it's a very powerful feature of the language. This made me wonder and experiment, and I can't figure out a nice solution to the following problem. Say I have the following code: interface WidgetProducerConsumer { fun produce(): Widget fun consume(widget: Widget) companion object { fun getStringWidgetProducerConsumer(): WidgetProducerConsumer { return StringWidgetProducerConsumer()...
  • u

    user

    07/10/2022, 2:11 PM
    How to update data item in RecyclerView responded by a ClickListener in another activity I am trying to make a RecyclerView in which I can delete or edit the individual item. I could find how to implement the delete function, but not the edit. I have the first activity 'EmergencyCallActivity' which contains the list of items in the form of RecyclerView. If I click the edit icon of each item, the activity changes into the second one 'AddPhoneBookActivity' where I can write down the NAME and PHONE NUMBER of a person on editText to modify the information of the selected item. Once...
  • u

    user

    07/10/2022, 2:11 PM
    Android mapbox view annontion in fragment not working Android mapbox view annontion in fragment not working: I try to using mapbox in fragment and add view annotation to it, the map working but the view annotation does not appear on the map. (The code is the same as the example in the documents: https://docs.mapbox.com/android/maps/guides/annotations/view-annotations/) my code: class MapFragment : Fragment() { var binding:...
  • u

    user

    07/10/2022, 2:11 PM
    How to create a button to clear android app cache I want to create a button in Android studio that should be part of the menu in my android WebView app, which automatically clears the cache of the application whenever a user clicks it. How do I do that please? I am a beginner, so detailed explanation will be much appreciated!
  • u

    user

    07/10/2022, 2:31 PM
    I'm getting an issue to create two retrofit instance using Hilt Dagger I'm setting up two different URL using @Named Annotation but I'm getting an errror in AppPostServices interface. @Module @InstallIn(SingletonComponent::class) object AppModule { //Retrofit Instance 1 @Singleton @Provides @Named("RetrofitInstanceDummy") fun getRetrofitDummyInstance(): Retrofit = Retrofit.Builder().baseUrl(BaseUrls). addConverterFactory(GsonConverterFactory.create()).build() //Retrofit Instance 2 @Singleton @Provides @Named("RetrofitInstance")...
  • u

    user

    07/10/2022, 2:51 PM
    Display healthService data such as step in AmbientMode (Android wear) I want to display health-service data such as step, pace, etc in AmbientMode. But HealthServices seems to go into Sleep state when entering ambient mode. I tried using AmbientUpdate with AlarmManager, but HealthServices did not wake up. Please let me know if you have a good way to solve this problem. I want to change the data of the screen in the middle in AmbientMode. Please help me.
  • u

    user

    07/10/2022, 3:11 PM
    how to fix okhttp3 socket timeout which is leading to android app crash? Dont know why this error is coming and from which api call. using retrofit Earlier this error was not coming but now this is coming frequently My read and write timeout is set to 10000ms and it hard to trace the problem as this happens intermittently Fatal Exception: java.net.SocketTimeoutException timeout okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException (Http2Stream.kt:677) okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut (Http2Stream.kt:686)...
  • u

    user

    07/10/2022, 3:11 PM
    How to optimize a complex activity has more than 80 views Overview: I am trying to create this activity where it has X subjects (in this case 12) each subject has its own CardView, each card has three TextEdits that calculate the average of that subject and show it in the TextView of that card, and by the end after a button click it shows the average of all the subjects together in another activity. Problem: So I hard coded each card its own as you can see...(code and image of only two cards) and I got a Warning says that this activity has more than...
  • u

    user

    07/10/2022, 4:11 PM
    return ResultRow for kotlin exposed upsert I am using kotlin-exposed for update/upsert query , I could see that update query return int whereas upsert returns unit, I was looking for a work around where I can find the updated resultRow if it is feasible. the current repository layer looks something like this suspend fun set(entity: SomeEntity) suspend fun get(entityId: Int): SomeEntity? here get is using EntityTable.select { }.firstOrNull() and I am able to map it back to my entity , whereas in set I have options of using upsert or...
  • u

    user

    07/10/2022, 4:31 PM
    Mongodb query returns null for nested queries (KMongo) I'm new to ktor and am writing an application using it. I'm trying to add authors and their book titles and retrieve them from the database. My schema is given below. (authors is my collection name) authors = [ { name: "Author1", books: [ {title:"Book1"}, {title:"Book2"} ] } ] I'm trying to check whether a book title has already been added under a particular author. So I wrote a findBookitemBytitle function as shown below. My issue is that every time I'm getting a null result. Even...
  • u

    user

    07/10/2022, 4:31 PM
    Which Geolocation SDK for Android I am working on an Android mobile app using Kotlin, it does not have to support older versions. I need to be able to find the user's current location, and I also need to be able to select a location from a map. I know there is an android.location package available that is free, but it doesn't support maps, is that correct? The google cloud maps API supports maps, but it is not free. This app will have very low usage in terms of installs and requests for maps so I think it will still be free...
  • u

    user

    07/10/2022, 4:51 PM
    How to skip loginScreen and passwordScreen after launch the app Hello i would like to know How to skip the loginScreen and the passwordScreen and move to homeScreen after launching the app because i have Stored the username and password in Datastore, So how can i do that? Here is my code: MainActivity.kt setContent { EEETheme { // A surface container using the 'background' // color from the theme Surface( modifier = Modifier.fillMaxSize(), color = MaterialTheme.colors.background ) {...
  • u

    user

    07/10/2022, 4:51 PM
    How do I set up automatic updates via the source code in my Android Studio app? How do I set up automatic updates via the source code in my Android Studio app? The app is not in the PlayStore.
  • u

    user

    07/10/2022, 5:11 PM
    Draw in real-time a line that corresponds to the user's route using Mapbox and Android I would like to draw a path in realtime into a MapView (v10.6.0) using Android (and Kotlin). I do not need Turn-by-Turn Navigation features, but only to track the user's actual route. The approach I am planning to use (unless an easier/better solution comes up) is using a listener as described in the documentation (Display the user's location) that updates the camera every time the user...
  • u

    user

    07/10/2022, 6:51 PM
    How to select from database with "where" parameter SpringBoot? I would like to get one single entry from database. I have such entry model: @Table("USERS") data class User(@Id val id: String?, val login: String, val password: String) and such controller: @RestController class MessageResource(val service: MessageService) { @GetMapping fun index(): List = service.findMessages() @PostMapping fun post(@RequestBody user: User) { service.post(user) } @GetMapping("/user") fun getByLogin(@RequestParam("login") login:...
  • u

    user

    07/10/2022, 8:11 PM
    mocking actual API call during unittesting retrofit interface learning about retrofit but couldn't write the tests for it. I came from jest background and struggling to test two things: that the call was making to a specific end point and its status. import okhttp3.ResponseBody import retrofit2.Response import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import retrofit2.http.GET import retrofit2.http.Query interface WeatherAPI { @GET("current.json") suspend fun getCurrentWeatherData(@Query("key") apiKey: String,...
  • u

    user

    07/10/2022, 9:11 PM
    LateError (LateInitializationError: Field 'image' has not been initialized.) I'm making an application to hide messages in pictures, everything is running smoothly and i have declared everything, but there is a problem i'm having "LateError (LateInitializationError: Field 'image' has not been initialized.)". can anyone help me? import 'dart:io'; import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:hideimage/action/decode_req.dart'; import 'package:hideimage/action/encode_req.dart'; import 'package:hideimage/fight/decode.dart'; import...
  • u

    user

    07/10/2022, 9:11 PM
    How to save data on disk before app closed? There is WebView with CustomWebViewClient that update a cookie in StateFlow. I want to save it into preferences DataStore. But the cookie update too frequencies on each redirect url. It seems don't right to call operations with memory storage on disk so often. class CustomWebViewClient() : WebViewClient() { private val cookieManager = CookieManager.getInstance() private val _cookieState = MutableStateFlow("") val cookieState = _cookieState.asStateFlow() override fun...
  • u

    user

    07/10/2022, 9:31 PM
    Path class from stdlib has no function "of" In this code, as in this example, I try to configure resolver via DirectoryCodeResolver, but its parameter Path.of("somePath") is incorrect, there is no such function. Path is from java.nio.file.Path, but there is no of(). Maybe, some file defines an extension for Path class? package com.example import io.ktor.server.engine.*...
  • u

    user

    07/10/2022, 9:31 PM
    Android Groupie - context menu on long press Using Groupie, along with view bindings, I can't figure out how to open a context menu when long pressing a Item. I have a couple of overrides in the fragment which has the GroupieAdapter: override fun onCreateContextMenu( menu: ContextMenu, v: View, menuInfo: ContextMenu.ContextMenuInfo? ) { super.onCreateContextMenu(menu, v, menuInfo) menu.setHeaderTitle("Pick option") requireActivity().menuInflater.inflate(R.menu.save_game_item_context_menu, menu) } override fun...
  • u

    user

    07/10/2022, 9:51 PM
    [JETPACK COMPOSE]: is there a way to restart whole app progrimatically? I need a way to make my app close and opens again. Or just restart everything inside of it. Since the issue with my app can be fixed by closing app and opening again (When creating user the loading function to firebase the collection inside user document does not load for some reason)
  • u

    user

    07/10/2022, 10:51 PM
    inputsheet radio button select doesn't work i'm using the maxkeppeler code library for sheets, and i have a bottom sheet to select the time option for the timer that i have. When i select the option and click in "ok", it doesn't do what is supposed to. the code library: https://github.com/maxkeppeler/sheets#input private fun timerSheet(){ val timerSheet = InputSheet().build(this) { style(SheetStyle.BOTTOM_SHEET)...
  • u

    user

    07/10/2022, 11:11 PM
    Broadcast Receiver in ViewModel I'm trying to receive SMS messages and later do some things with them. To see if I can go forward with my idea I set up a broadcast receiver but I can't seem to get the data in the viewmodel. class SmsReceiver(private val homeViewModel: HomeViewModel) : BroadcastReceiver() { private val scope = CoroutineScope(SupervisorJob()) override fun onReceive(context: Context?, intent: Intent?) { val pendingResult: PendingResult = goAsync() scope.launch(Dispatchers.IO) { try {...
  • u

    user

    07/10/2022, 11:11 PM
    How do I initialize these arrays? I want to have a class that stores three sets of 30 Foos each. I can declare them as arrays of Foo but I don't know how I can initialize them (give them default values) with 30 elements. data class Container ( val first: Array, val second: Array, val third: Array, ) data class Foo (val a: Int, val b: Int)
  • u

    user

    07/11/2022, 12:11 AM
    Kotline coroutine:how to check a coroutine builder created a root coroutine In the kotline coroutine exceptions doc. The doc mentioned: When these builders are used to create a root coroutine, that is not a child of another coroutine My question is how to check a coroutine scope is a not a child of another coroutine programmablely? I can not find any member function from CoroutineScope to indicate the current coroutine scocpe is a root coroutine or not
Powered by Linen
Title
u

user

07/11/2022, 12:11 AM
Kotline coroutine:how to check a coroutine builder created a root coroutine In the kotline coroutine exceptions doc. The doc mentioned: When these builders are used to create a root coroutine, that is not a child of another coroutine My question is how to check a coroutine scope is a not a child of another coroutine programmablely? I can not find any member function from CoroutineScope to indicate the current coroutine scocpe is a root coroutine or not
View count: 6