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/07/2022, 7:11 AM
    The RecyclerView doesn't retrieve any data from Firebase and doesn't show any data I just started working with Android Studio, and I've been trying to figure out what's wrong with this code for a few days now. When I run the program it shows nothing, and also there is no errors from Android Studio. I read the posts on the subject, but unfortunately I found nothing appropriate. This is my activity class. package ie.wit.donationx.activities import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import androidx.recyclerview.widget.LinearLayoutManager import...
  • u

    user

    07/07/2022, 7:11 AM
    Cannot figure out how to store value that I get from location services and call the api using those values Inside my Fragment File Here I am try to call locationProvider to get the latitude and longitude. And once i get those i want to call api to get the weather data weatherApi. I cannot initialise variables inside locationProvider.lastLocation.addOnSuccessListener also i cannot call weatherApi inside the locationProvider.lastLocation.addOnSuccessListener as it suspend function. I tried many different approaches but nothing seems to work. Right now i am using global variable to store the value of...
  • u

    user

    07/07/2022, 7:31 AM
    How can we get the key of the current user from the realtime database when the key of the user is the username in KOTLIN

    The codeâ–¾

    This is our code, we just want to display the current user's key, that's it so how should be do that. Currently the code gives the output of all the keys and not the current user key As output we are getting the values : Asif, Test24 and Vaishnavi in the variable key The image is of the real time database

    The image of real time database â–¾

  • u

    user

    07/07/2022, 7:31 AM
    Should I get rid of big switch case? I have a factory which includes many HTML attribute generators which returns one of them based on the type of attribute, so I wanted to see if there is a better way of doing this. class AttributeHtmlGeneratorFactory { fun create(property: String): AttributeHtmlGenerator { when (property) { "animation" -> { return AnimationHtmlGenerator() } ... "left", "top" -> { return PositionHtmlGenerator()...
  • u

    user

    07/07/2022, 7:31 AM
    Auto scroll on Recyclerview I create a RecyclerView with auto scroll functionality using Runnable task. My list is scroll perfectly upto the end of the list. What I want - suppose there are 1-2-3 items in list then again show 1-2-3 after ending the list in RecyclerView. what I had done val partner_recyclerView: RecyclerView = findViewById(R.id.partnership_slider) var partnerAdapter : MyPartnerAdapter = MyPartnerAdapter(partnerImageList) var linearLayoutManager : LinearLayoutManager =...
  • u

    user

    07/07/2022, 7:31 AM
    Checking if entry exists I'm trying to create a login app. I want it to do nothing more than either store the account info on a db if the username is not already used. Problem is, no matter what I try, I cannot check if the username is already in the db I've tried to get both LiveData from my query, as well as String?, as shown below with no success @Entity(tableName = "Users_table") data class User( @PrimaryKey var username: String, @ColumnInfo var firstName: String, @ColumnInfo var lastName: String,...
  • u

    user

    07/07/2022, 7:51 AM
    Viewpager2 is not loading fragment on clicking tab ,but works on swiping I am using ViewPager2 with Tablayout . Initially everything works fine. ie, both swipe and clicking on Tab ,loads the correct fragment. Say I have 3 fragments Tab A, Tab B and Tab C. I need to open other fragments from Tab B ,say Tab B1.Tab B1 is opened and on pressing back button it goes back to Tab B. Now when I click on Tab A, it higlights TabA, but the fragment for Tab A is not loaded. But if we swipe, its working properly . Below is my Viewpager code. ViewPager code private val...
  • u

    user

    07/07/2022, 7:51 AM
    How to inject interface into class with Hilt in Android In my application I want use MVP structure and for this I create Contracts file. Contract codes: interface ShopContracts { interface View { fun showAllData(data: List) } interface Presenter : BasePresenter { fun loadAllShop() } } I use this interface into presenter class, in this class I want set 2 file in constructor such as below : class ShopPresenter @Inject constructor(private val repository: ShopRepository, private val view: ShopContracts.View) :...
  • u

    user

    07/07/2022, 8:11 AM
    How to import a Kotlin Library in IntelliJ So i want to use the Serialization Library in my kotlin project, and from what i can gather from this page, i must use this: "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2", to do so, now i use "IntelliJ" as my build system, so i went to the project structure, and in libraries, clicked the + sign, clicked on "From Maven" and put this as the link to the library, and it...
  • u

    user

    07/07/2022, 8:31 AM
    Kotlin: Type inference failed. The value of the type parameter T should be mentioned in input types I'm new to Kotlin, for the piece of the below code: fun a(stcd: String) { val res = mutableSetOf() val aaa = mutableListOf() aaa.stream().filter { x: Map -> x.isNotEmpty() } .filter { x: Map -> x.values.contains(stcd) // throws error }.forEach { x: Map -> x.forEach { (k: String, v: Set?) -> res.add(k) } } } Could anyone point out why contains throws error:Type...
  • u

    user

    07/07/2022, 8:31 AM
    Is green Dao supported by kotlin? I'm converting my existing java project into the Kotlin , while during this I come across the problem that unresolved ref to 'dao', I tried changing the sequence of greendao & Kotlin dependency as but still facing the same issue
  • u

    user

    07/07/2022, 9:11 AM
    Couldn't make a guess for com.Rapcrushers.app.customviews.MageNativeTextView I am receiving the error "Cause: couldn't make a guess for com.Rapcrushers.app.customviews.MageNativeTextView" while rebiulding the project. I think this issue is because of the capital "R" in package name of my app. But i can't change it to small "r" since app is already live on play store and have 1000(s) of installs on it. Please suggest a solution to fix this without changing package name. Package name = com.Rapcrushers.app folder name = customviews Class name = MageNativeTextView ( A...
  • u

    user

    07/07/2022, 9:11 AM
    Android can not resolved method registerForActivityResult Added this dependency implementation("androidx.activity:activity-ktx:1.5.0") implementation("androidx.fragment:fragment-ktx:1.5.0") implementation("androidx.appcompat:appcompat:1.4.2")

    I am write code thisâ–¾

  • u

    user

    07/07/2022, 9:51 AM
    Firebase not sending notifications after account change/replacing firebase account I am trying to implement how to push notifications from firebase. I have added the dependencies and made a project in my firebase account and connected my app. It initially worked fine but I changed the firebase account that is associated with the app to another(2nd account) then I saw that I did not receive any notification so I deleted my project on the 2nd account and replaced my json files with the first one and reconnected to it again but I am not receiving any notification which was...
  • u

    user

    07/07/2022, 9:51 AM
    Creating a matrix with values in Kotlin in convenience I want to create the following one with a fancy notation: arrayOf(intArrayOf(4, 5), intArrayOf(5, 8), intArrayOf(1, 9), intArrayOf(8, 10), intArrayOf(1, 6)) at least, cannot I achieve something that looks as follows: arrayOf((4, 5), (5, 8), (1, 9), (8, 10), (1, 6)) because it is pretty awkward to rewrite intArrayOf for each row to put in. Note that I do not ask for the following syntax I'm aware of which is used to initialize an empty matrix with values that are either same or following a...
  • u

    user

    07/07/2022, 9:51 AM
    Converting string into a date type in Kotlin I'm sending a date as a string to kotlin app: What i recive is: "7/07/2022" now I want to convert it into a date type and compare with today's date. Any ideas? I have to recive it as a string.
  • u

    user

    07/07/2022, 10:11 AM
    Android: How to get zip file by Intent? val intent = Intent(Intent.ACTION_GET_CONTENT).apply { type = "application/zip" addCategory(Intent.CATEGORY_OPENABLE) } startActivityForResult(intent , CODE) and in onActivityResult, I got 0 length of file override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == CODE){ val uri = data?.data!! val...
  • u

    user

    07/07/2022, 10:51 AM
    java.lang.IllegalArgumentException: A required type converter for Dao is missing in the database configuration I have a type converter class but the app crashes when I try to use it in my database. Error message: java.lang.IllegalArgumentException: A required type converter (class com.example.weatherapp.util.WeatherTypeConverter) for com.example.weatherapp.data.database.WeatherDao is missing in the database configuration. code: @ProvidedTypeConverter class TypeConverter( private val gson:Gson ) { @TypeConverter fun toCurrentJson(current: Current): String { return gson.toJson(...
  • u

    user

    07/07/2022, 11:31 AM
    Android getCallerNumberVerificationStatus() always returns Connection.VERIFICATION_STATUS_NOT_VERIFIED I am implementing a Call Screening service to detect spam in Android by following the implementation here: https://developer.android.com/guide/topics/connectivity/telecom/prevent-spoofing?hl=bn-IN I have my call screening service setup, but I am always getting Connection.VERIFICATION_STATUS_NOT_VERIFIED when receiving a call. My onScreenCall override is run and I...
  • u

    user

    07/07/2022, 11:51 AM
    Getting response of a Chain of One Time Work Request in work manager in kotlin I have several worker classes that are scheduled as one-time requests, as below private fun createOneTimeWorkRequest(){ val imageWorker = OneTimeWorkRequestBuilder() .setConstraints(constraints) .addTag("imageWork") .build() val gpSurveyWorker = OneTimeWorkRequestBuilder() .setConstraints(constraints) .addTag("gpSurveyWork") .build() val villageSurveyWorker = OneTimeWorkRequestBuilder() .setConstraints(constraints)...
  • u

    user

    07/07/2022, 11:51 AM
    Change the SeekBar status with EditText and viceversa with 2 decimal space I could not find this use case where the seekBar has decimal value. I need a seekBar that ranges from 20,00 to 100000,00 ** First case: ** When the user scroll the seekBar it needs to reflect the progress to the Edittext ** Second case: ** When the user inputs a number ex(123,50) it has to reflect this value to the seekBar
  • u

    user

    07/07/2022, 12:31 PM
    Connecting Docker Container to Azure Application Insights I'm trying to monitor my services, which are running in a Azure Kubernetes cluster. I wanted to use https://docs.microsoft.com/en-us/azure/azure-monitor/app/java-in-process-agent. So I added (<a href="https://docs.microsoft.com/en-us/azure/azure-monitor/app/java-spring-boot" rel="nofollow...
  • u

    user

    07/07/2022, 12:31 PM
    How to deal with public and private key in a Spring Boot application? I would like to verify messages between clients with private and public key signatures in a Spring Boot application. What is the best way to do this? Any best practices?
  • u

    user

    07/07/2022, 12:31 PM
    Disable touch event for a sibling in a layout I've been trying to disable touch event for a fragment and app bar, but it's not working. I used view.isEnabled, isClickable and set to false, to disable touch event. fun disableClickWhenFabExpanded() { fragment_content.isClickable = false } fun enableClickWhenFabCollapsed() { fragment_content.isClickable = true } I don't know how to use onInterceptTouchEvent() on a fragment or view. I've been trying this way. fragment_content.onInterceptTouchEvent()and no...
  • u

    user

    07/07/2022, 12:31 PM
    Combine detectTapGestures and detectDragGesturesAfterLongPress? We need to be able to detect both taps and drag gestures after long press on the same component in Jetpack Compose. To detect taps we can do: Modifier.pointerInput(graphData) { detectTapGestures( ... ) } And to detect drag gestures after long press: Modifier.pointerInput(graphData) { detectDragGesturesAfterLongPress( ... ) } But it is not possible to use both at the same time, since the first detect* will consume the pointer events:...
  • u

    user

    07/07/2022, 12:51 PM
    Return two values from for loop in Kotlin I am trying to return two values from the array with the for loop, but am only getting the first value instead. data class Batches( var qty: Int?, var entries: List?, var entryIds: ArrayList?, var priceconfig: PriceConfig? ) { constructor() : this(0, null, null, null) } data class TruckEntry(var name: String?, var id: String?, var qty: Int?, var observed: Int?) { constructor() : this(null, null, null, null) } My function: private fun getBatchName(batches: Batches):...
  • u

    user

    07/07/2022, 1:11 PM
    Wrong navigation with TalkBack I have the following problem I have a layout with multiple views, one is a custom view which contains two textviews, lets say A and B, and a RecyclerView, lets call it C When I use TalkBack and I swipe right, it goes from A to B and from B to C correctly. When I go back it goes from B to A correctly, but when it focuses C (first element of the RecyclerView) and I swipe left, it jumps to the element that's before the custom view in the layout. Something like this: <a...
  • u

    user

    07/07/2022, 1:11 PM
    Search with jooq if a jsonb column contains a specific value doesnt work properly I have to create a query with jooq that checks to see if a jsonb column contains a specific value that I pass to it. I've tried doing something like this: jooq.selectFrom(Tables.TRANSACTIONS_TABLE) .where( TRANSACTIONS_TABLE.MESSAGE .contains(JsonNodeFactory.instance.objectNode().put("transactionId", transactionId)) ) .fetch { TransactionTable.fromRecord(it) } But I'm not really sure why it's not working, it's not...
  • u

    user

    07/07/2022, 1:11 PM
    How to get the value of another function synchronously I am using the ktor websocket module When I send data to the client, how do I get the data back from the client after this send? val result = serverSession.send(json) // result Just like this It is actually the Unit type But I want to get the String
  • u

    user

    07/07/2022, 1:31 PM
    How to create custom event with the shortest way? There is CustomWebViewClient with override function onPageFinished. What is the shortest way to notify MainViewModel about the function triggered? I mean some event. I suppose that can use StateFlow, something like this: class MainViewModel : ViewModel() { init { val client = CustomWebViewClient() viewModelScope.launch { client.onPageFinished.collect { // ... } } } } class CustomWebViewClient() : WebViewClient() {...
Powered by Linen
Title
u

user

07/07/2022, 1:31 PM
How to create custom event with the shortest way? There is CustomWebViewClient with override function onPageFinished. What is the shortest way to notify MainViewModel about the function triggered? I mean some event. I suppose that can use StateFlow, something like this: class MainViewModel : ViewModel() { init { val client = CustomWebViewClient() viewModelScope.launch { client.onPageFinished.collect { // ... } } } } class CustomWebViewClient() : WebViewClient() {...
View count: 2