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/18/2022, 7:21 PM
    Custom Notification is not displayed on android 12 I have a problem with my notification code, in my device with Android 9 It works good but not in Android 12. I notice that maybe It's something related to the RemoteViews but I'm not sure. This is my code: object NotificationUtils { private fun createNotification(context: Context, activity: Activity, layout: Int, channelId: String ): Notification { return NotificationCompat.Builder(context, channelId) .setCustomContentView(RemoteViews(activity.packageName, layout))...
  • u

    user

    07/18/2022, 8:41 PM
    Gradle Issues in Android Studio I'm new to Android development with Kotlin. In the course I'm currently taking, there's a Java file I'm meant to convert to Kotlin. I'm stuck with this Gradle problem and can't find my way around. I have no prior Java experience. What can I do to resolve this issue?

    enter image description here▾

  • u

    user

    07/18/2022, 8:41 PM
    Upsert query in Dao I am developing an application using Room. The operation is simple, if the table has the same letter, the letterscore will increase by 1, otherwise it will be added and letterscore will be 0. In my Dao, I wrote a query as below to upsert the data, but it gives compound operator>, LIMIT, ORDER, comma or semicolon expected, got 'ON' error in the "ON" part: @Dao interface LetterDao { @Query("INSERT INTO letter_table(letter, letterScore) VALUES (:letter, :letterScore) ON CONFLICT(letter)...
  • u

    user

    07/18/2022, 9:01 PM
    LazyColumn Acknowledging Key inside another Column? basically I have a giant Lazy Column, but I only want some components inside another component to launch the animation when that child component is visible. I am having so much trouble with the keys, I want to put a key ONLY on a certain composable within the LazyColumn. My issue is that the 'isItemWithKeyInView' is TRUE once the entire Column is showing, so the user is not able to see the animation since its not on the screen yet, but the same Column is visible. I tried putting a...
  • u

    user

    07/18/2022, 9:21 PM
    Use DI ( Dagger 2/Hilt ) at runtime without broke MVVM pattern? suppose i need to let user login at runtime using MVVM and DI patterns and i have Repository that have function to make login class RepositoryLogin @Inject constructor() { fun login(login: Login){ ... } } Now we need ViewModel that pass this Login object to our Repository at runtime, here is some of my solution: Use @AssistedInject to construct ViewModel at runtime with parameters and call "login" function that creates inside in viewModel an istance of Login class. But in...
  • u

    user

    07/18/2022, 10:01 PM
    Jackson kotlin inheritance deserialize problem I am using jackson-module-kotlin:2.13.3 and retrofit2:converter-jackson:2.7.2 in android project. I have a field 'status' that I receive and from it I understand which class to convert further, but the problem is that in descendant classes it becomes null. Main code is in Test.kt below. ResponseSuccessAbstract.kt: @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "status") @JsonSubTypes( JsonSubTypes.Type(value =...
  • u

    user

    07/18/2022, 10:21 PM
    Why documentt.data.getValue() gives empty string? Please help my to get a value from Firestore I have a Firestore database where "adminData" collection but only single value is essential. I will like to retrieve it from the firebase database and store it in string. Can you please help me with the implementation in android studio using Kotlin? val myString : StringBuffer = StringBuffer() var db = FirebaseFirestore.getInstance() db.collection("adminData").get() .addOnCompleteListener { it -> if(it.isSuccessful) {...
  • u

    user

    07/18/2022, 10:21 PM
    Change background color of fragments dynamically from a switch I am trying to have all fragments change to the background color of red using a SwitchPreferenceCompat but am having trouble writing the listener code and MainActivity code. I have tried some things but am not too familiar with how to write the listener code to be able to write the mainactivity code to use it properly. I am not really looking for a solution but rather being pointed in the right direction. Thank you Here's the relevant code: Preferences xml...
  • u

    user

    07/18/2022, 11:01 PM
    What is the complexity of the groupingBy{ it }.eachCount() operation? What is the time-complexity of the groupingBy{ it }.eachCount() operation? fun main() { val a = listOf(1, 1, 3, 3, 3, 5, 8, 8) val counter = a.groupingBy { it }.eachCount() println(counter) } Here is the source code for both functions: public actual fun Grouping.eachCount(): Map = foldTo(destination = mutableMapOf(), initialValueSelector = { _, _ -> kotlin.jvm.internal.Ref.IntRef() }, operation = { _, acc, _ -> acc.apply { element += 1 } })...
  • u

    user

    07/18/2022, 11:21 PM
    Class 'ListHerbalAdapter' is not abstract and does not implement base class member public abstract fun getItemCount `class ListHerbalAdapter(private val listHerbal: ArrayList) : RecyclerView.Adapter() { var onItemClick : ((Herbal) -> Unit)? = null override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ListViewHolder { val view: View = LayoutInflater.from(parent.context).inflate(R.layout.item_row_herbal, parent, false) return ListViewHolder(view) } override fun onBindViewHolder(holder: ListViewHolder, position: Int) { val herbal = listHerbal[position]...
  • u

    user

    07/19/2022, 2:41 AM
    How to port ScrollView written in kotlin to flutter The question is difficult to understand due to machine translation. Sorry. Scrolling view with scaling and panning in Kotlin. I would like to port this to flutter, but GestureLisner is not working and I don't know how to solve it. The XML Layout itself is displayed, but the GestureLisner for scaling and panning is not detected. Can anyone help me with a solution? Below is the code created in Kotlin. We are aiming to port this. class MainActivity : AppCompatActivity() { private lateinit var...
  • u

    user

    07/19/2022, 3:41 AM
    how to start app on boot in android tv box I have an application on android tv box and I want to start this app when TV start or this android box connects to TV. and also I work in flutter but this app is only on Android. I add this to AndroidManifest.xml: and this is BootReciever package com.example.app import android.content.BroadcastReceiver import android.content.Context; import android.content.Intent; import com.example.insoft_web.MainActivity class BootReciever:...
  • u

    user

    07/19/2022, 5:21 AM
    How to integrate google pay payment gateway in kotlin android project, anybody help pls In my kotlin existing project, how to integrate google pay app when i click pay now button. When i click pay now option, app should check whether gpay app installed or not and if installed means through gpay app payment can be done.
  • u

    user

    07/19/2022, 5:21 AM
    Callback returns a null arraylist when getting data from firestore I have created a callback function to get the arraylist of conversations when the task is completed. It gets all the data and adds it to the list but still, it returns null. Is there a way to fix this issue? fetch conversations method: private fun fetchConversations(fetchConversationsCallback: FetchConversationsCallback) { db.collection("rooms") .addSnapshotListener { value, error -> if (error != null) { Log.d(TAG, "Get failed with ",...
  • u

    user

    07/19/2022, 5:41 AM
    Kotlin - Achieving Executors.newSingleThreadExecutor behaviour using coroutines Executors.newSingleThreadExecutor queues the tasks registered to it and then executes them sequentially. The following code: val singleThreadedExecutor = Executors.newSingleThreadExecutor() (0..10).forEach { i -> singleThreadedExecutor.execute { if (i % 2 == 0) { Thread.sleep(2000) } else { Thread.sleep(1000) } println(i) } } outputs this: I/System.out: 0 I/System.out: 1 I/System.out: 2 I/System.out: 3 I/System.out: 4...
  • u

    user

    07/19/2022, 5:41 AM
    Android - Listen for keys on the broadcast receiver I want to know how to listen for keys (like f1, f2, etc) on the broadcast receiver? Note: I have a USB broadcast receiver. I want to listen for keys on it.
  • u

    user

    07/19/2022, 5:41 AM
    How to share specific event linke we share video and use click on the link and go to that video I want to share a specific link we share a video and click on the link and go to that video. I use the firebase dynamic link. And I achieve the image format by the below code, I want for the video, I didn't get the documentation for the video. Anyone knows about it Share the knowledge Firebase.dynamicLinks.shortLinkAsync(ShortDynamicLink.Suffix.SHORT) { link = deepLink domainUriPrefix = "https://xxxxx.xxx.xxxx" socialMetaTagParameters { title = "yyyyyyy"...
  • u

    user

    07/19/2022, 6:01 AM
    How to truncate csv file to n of rows not reading the whole file I have big csv(12 gb), so I can't read it in memory, and I need only 100 rows of them and save it back(truncate). Has java such api?
  • u

    user

    07/19/2022, 6:01 AM
    How to Get Data From Firebase Dynamic Link I have Make Google Map Integration Of My Application. Then Implement the firebase dynamic link when user and driver both location driection show on map then share the dynamic url and just click show in app also get data in log in string format. how to get string format data access from one variable which i store in project
  • u

    user

    07/19/2022, 6:01 AM
    Android MaterialCardView's drop shadow/elevation disappears when rotating it 180 degrees Summarize the problem: I am working on a paint app, and in this app, the user has the option to rotate the canvas, this feature can be useful in some scenarios. The problem I am having, is that when I rotate the CardView, which hosts the canvas/bitmap, 180 degrees -- the drop shadow gets lost. I do not get this problem when I rotate the CardView 90 degrees, only 180 degrees. Describe what you've tried I've tried many things, such as giving the CardView more space so that the drop shadow will...
  • u

    user

    07/19/2022, 7:21 AM
    How to create combine title and menu list in one box (drop down ) in jetpack compose? I have created a drop down menu using jetpack compose. here used card for the menu title. I just want to combine title box of drop down and body box of drop down using jetpack compose. Dropdown menu
  • u

    user

    07/19/2022, 7:21 AM
    Android - How to set a key shortcut for app programmatically I want when F1 has pressed on the phone my app opens. Is there any way to programmatically set the F1 key shortcut for opening my app on android?
  • u

    user

    07/19/2022, 7:41 AM
    How to configure Kotlin for tests in Android Studio I just started using Kotlin in my Android project. The project compiles and runs. But when I try to convert an instrumented test file from Java to Kotlin i get the dialog "Kotlin is not configured in the project. You will have to configure Kotlin in project before performing a conversion." Here is my build.gradle file import com.android.ddmlib.IDevice import com.android.ddmlib.NullOutputReceiver apply plugin: 'com.android.application' apply plugin: 'kotlin-android' //...
  • u

    user

    07/19/2022, 7:41 AM
    Problem with ViewModelFactory in Android Studio I am trying to create a ViewModel Factory with the below code: class TestViewModelFactory(private val testId: UUID) : ViewModelProvider.Factory { override fun create(modelClass: Class): T { return TestViewModel(testId) as T } } However, against the class definition, there is a compilation error saying: Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option Can someone help me with what this problem is about?
  • u

    user

    07/19/2022, 8:21 AM
    Cursor goes to start(left) of the EditText after a character is entered or deleted everything works as it should except the problem is that the cursor just goes to the start after a character is deleted or inputted, i want to it to stay at the same position This is the code: binding.includeFirstSeekbar.seekBar.setOnSeekBarChangeListener(object : OnSeekBarChangeListener { override fun onProgressChanged(seekBar: SeekBar, progress: Int, b: Boolean) { val number = java.lang.Double.valueOf(progress.toString())/100 val dec =...
  • u

    user

    07/19/2022, 8:21 AM
    null result variables in fragment android kotlin I´m traying to send variables to my fragment in android with kotlin. My problem it´s when i load my fragment this values it´s null. Im sending my data so: if (jsonObject != null) { val dataJson: JSONObject = jsonObject.getJSONObject("user") val name = dataJson.getString("name") val address = dataJson.getString("address") val email = dataJson.getString("email") val phone =...
  • u

    user

    07/19/2022, 8:21 AM
    Writing a unit test for a function in Kotlin I am new to writing Unit tests. I have a function that takes as input an Android Package name, and outputs the SHA-256 digest for that package. Here it is: fun getSignatureByteArray(packageInfo: PackageInfo): ByteArray { var outputDigestByteArray: ByteArray = byteArrayOf() val signature = packageInfo.signingInfo.apkContentsSigners[0] val digest = MessageDigest.getInstance("SHA256").apply { signature.toByteArray() }.digest() val intermediateString =...
  • u

    user

    07/19/2022, 8:21 AM
    Get kotlin class failed with dynamic string but works with constant I just call a method class through this line : val instance = Class.forName(nameClass).kotlin.objectInstance When I set the nameClass with a constant value (see below) it's work. private const val PROVIDER_CLASS = "com.abc.xyz.feature.DynamicFeatureImpl\$Provider" fun method() { val instance = Class.forName(PROVIDER_CLASS).kotlin.objectInstance } But, when I set the nameClass to string (not constant), like this fun method() { val nameClass =...
  • u

    user

    07/19/2022, 9:01 AM
    Verifying signature from .ps7 file (PKCS#7/CMS) in Kotlin I have a file fileA.json.p7s and I'm trying to validate the detached signature using Bouncy Castle. However, the code fails on verification and returns the error: org.bouncycastle.cms.CMSSignerDigestMismatchException: message-digest attribute value does not match calculated value Does anyone know how to fix this error? Here is my code: fun verifySignature(): Boolean { val signatureContent = File("src/test/resources/fileA.json.p7s").readBytes() val cmsSignedData...
  • u

    user

    07/19/2022, 9:01 AM
    Intellij - running a project after java upgrade fails I have a project with 3 modules. I am running them with Intellij. Everything worked fine until project was upgraded to java 17, I ran following commands in terminal: sdk install java 17.0.3-tem sdk use java 17.0.3-tem In Intellij preferences Compiler -> Java Compiler -> Project bytcode version is set to 17 as well as all per module bytecode target versions. I have tried to use both javac and eclipse compiler, also I have set the Gradle Jvm to temurin-17 in Intellij Build Tools -> Gradle, but...
Powered by Linen
Title
u

user

07/19/2022, 9:01 AM
Intellij - running a project after java upgrade fails I have a project with 3 modules. I am running them with Intellij. Everything worked fine until project was upgraded to java 17, I ran following commands in terminal: sdk install java 17.0.3-tem sdk use java 17.0.3-tem In Intellij preferences Compiler -> Java Compiler -> Project bytcode version is set to 17 as well as all per module bytecode target versions. I have tried to use both javac and eclipse compiler, also I have set the Gradle Jvm to temurin-17 in Intellij Build Tools -> Gradle, but...
View count: 6