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, 12:11 PM
    how to insert data into room and sequentially get id from tables to insert new data? How do I sequentially add data to the database? I need to add two words to the "word" table , then get their rowid and add to the "word pair" table, then get the rowid of the "word pair" table and add to the "word base and word pairs" table Here is my code inside fragmemnt: viewLifecycleOwner.lifecycleScope.launch { var languageId = vocabularyViewModel.getLanguageId(word.wordLanguage) // yet added to db var languageId2 = vocabularyViewModel.getLanguageId(word.translatedLanguage)...
  • u

    user

    06/23/2022, 12:11 PM
    error when I try to draw a route between two markers I have recently started studying kotlin and android studio, in my application I would like to trace a path between two points, in my case marckers, my problem arises when I try to trace a path between two points, I get this error: Cannot access class 'org.osmdroid.views.overlay.PathOverlay'. Check your module classpath for missing or conflicting dependencies. how can i solve? below is my code: class MainActivity : AppCompatActivity() { private lateinit var mapView : MapView private lateinit...
  • u

    user

    06/23/2022, 12:31 PM
    No transactional EntityManager found, is your test running in a transactional? I am writing tests for a repository, but BeforeAll annotation causes java.lang.IllegalStateException: No transactional EntityManager found, is your test running in a transactional? error. If I change it to BeforeEach the tests work, but that's not very efficient, since the same record is repeatedly written into the database. How can I fix this? My test class: @DataJpaTest @TestInstance(TestInstance.Lifecycle.PER_CLASS) @ActiveProfiles("testing") class RepositoryTest { @Autowired...
  • u

    user

    06/23/2022, 12:51 PM
    android.content.res.Resources$NotFoundException: Drawable compat_splash_screen_no_icon_background with resource ID #0x7f0801b6 I am getting this issue only for samsung galaxy devices- Galaxy Tab A, Galaxy A03 Core, Galaxy A02 Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.application/com.myapp.application.ui.MainActivity}: android.content.res.Resources$NotFoundException: Drawable com.app.application:drawable/compat_splash_screen_no_icon_background with resource ID #0x7f0801b6

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

  • u

    user

    06/23/2022, 12:51 PM
    Room returns java.lang.Object for all my suspended Dao functions I have a project with a Room database, which was working fine, and now for some reason I can't find out, it isn't anymore. I am getting the following error when compiling: C:\(...)\FlightDao.java:18: error: Not sure how to convert a Cursor to this method's return type (java.lang.Object). public abstract java.lang.Object getFlightById(int id, @org.jetbrains.annotations.NotNull() This is from a class that is generated from my Dao: @Dao interface FlightDao { @Query("SELECT * FROM...
  • u

    user

    06/23/2022, 12:51 PM
    Remove import when using Kotlin's @Deprecated "ReplaceWith" functionality I have a custom function MutableStateFlow.update(), which i want to deprecate in favor of the official "kotlinx.coroutines.flow.update" version. @Deprecated( message = "This is not thread safe. Use the official version from kotlinx.coroutines.flow.update", ReplaceWith("update(transformation)", "kotlinx.coroutines.flow.update"), DeprecationLevel.ERROR ) public inline fun MutableStateFlow.update(transformation: (previousValue: T) -> T) { value = transformation(value) } This...
  • u

    user

    06/23/2022, 1:11 PM
    CameraX preview usecase attachedSurfaceResolution property returns wrong resolution on some devices version: 1.1.0-beta03 problem devices: Samsung A51 A52 A70 S8 S21, One+ 6 correct devices: Mi 10T Pro, Redmi Note 10 Pro In our app we use preview usecase to transfer viewfinder frames from cameraX to openGL scene. We need to know strict resolution of frames in video stream to make correct scale and position transformation in openGL. On some samsung devices (see list and more) property returns 14401080 (aspect 4/3) and when we place unit on scene with 4/3 aspect we see stretched picture by...
  • u

    user

    06/23/2022, 1:11 PM
    NPE when retrieving from HashMap even though containsKey() returns true in multithreaded environment We are trying to store unique object for a particular key. When getMyObject is called in multithreaded environment we are getting null ptr exception at the time of return statement object SampleClass { fun getMyObject(Id : String) : MyObject { if(!myMap.containsKey(Id)) { synchronized(SampleClass) { if(!myMap.containsKey(Id)) { myMap[Id] = MyObject() } } }...
  • u

    user

    06/23/2022, 1:31 PM
    Kotlin app using camera does not return picture if camera is never launched before I've stuck for a while with annoying issue with emulator's camera in my app. (The same is repro on a real device) The camera is used from a dialog fragment to take a picture that later will be uploaded to remote host. private val cameraPermissionLauncher = registerForActivityResult( ActivityResultContracts.RequestPermission() ) { isGranted -> if (isGranted) { makeImageWithCamera() } else { dismiss() } } private val cameraLauncher = registerForActivityResult(...
  • u

    user

    06/23/2022, 1:31 PM
    Snackbar is attached to the layout but is shown at the top of the screen I try show snackbar on the top of my layout , but snackbar always appears at the top of the screen. How I can place the snackbar at the top of the container ? Container located in the middle of the screen fun View.showToast(snackBarProvider: SnackBarProvider, actionDuration: Int = 5000): Snackbar { ... return Snackbar.make(this, msg, duration).apply { action?.let { event -> setAction(actionText ?: "OK") { event.invoke() }.setDuration(actionDuration) } } } override fun...
  • u

    user

    06/23/2022, 1:51 PM
    Kotlin Login/Register Page Validation issues occurring requiring assistance On Login page and when pressing register, it takes you to register, but when clicking on register button on register page, it adds user to database regardless if info is provided or not and then takes you back to login page, where you are able to log in regardless if email and password is even entered. I want the validation to happen before the execution. Currently it does validate, but executes regardless. Please advise. import android.content.ContentValues import android.content.Intent...
  • u

    user

    06/23/2022, 1:51 PM
    How can I open gmail when click the button in jetpack compose? I have simple button in android jetpack compose, when I click the button, I want to open gmail and send mail to "android@gmail.com", is it possible? @Composable fun SimpleButton() { Button(onClick = { //your onclick code here }) { Text(text = "Simple Button") } }
  • u

    user

    06/23/2022, 2:11 PM
    Kotlin/JS jsRun gives error "[webpack-cli] TypeError: cli.isMultipleCompiler is not a function" I have a Kotlin multiplatform project with JVM and JS. When executing jsRun gradle task to start the webpack server, it fails with the following error: Waiting for changes to input files of tasks... (ctrl-d then enter to exit) [webpack-cli] TypeError: cli.isMultipleCompiler is not a function [webpack-cli] TypeError: cli.isMultipleCompiler is not a function at Command. (C:\MyProject\build\js\node_modules\@webpack-cli\serve\lib\index.js:146:35) at async Promise.all (index 1) at...
  • u

    user

    06/23/2022, 2:11 PM
    Execution failed for task ':app:testDebugUnitTest'. > No tests found for given includes: [com.*](filter.includeTestsMatching) I'm trying to migrate a project from JUnit 4 to 5. The project has had a lot of migrations lately, including the swap from Groovy DSL to Kotlin DSL, Mockito to Mockk and from 'legacy' xml to JetPack Compose. However, when I try to migrate to JUnit 5, I keep getting the error which was mentioned in the title. I feel like I have tried everything there is, but for some reason project setups which should be working, do not seem to actually be working. build.gradle (project) buildscript {...
  • u

    user

    06/23/2022, 2:51 PM
    Ktor/WebSocket - auto reconnect I'm using Ktor Websocket in a multiplatform project (Android/iOS). I saw auto-retry for http request, but no option for websocket connection. Does it work with Ktor websocket or any other option?
  • u

    user

    06/23/2022, 3:11 PM
    How to use Spannable in text kotlin Hey I am learning spannable text in Android kotlin. I read everywhere how to use spannable text. I want to bold rather than search text i.e. For example 1 val value = "high blood pressure" val searchText = "Blood" Output:- high blood pressure blood will not bold and other high and pressure will be bold in text view. For example 2 val value = "diabetes" val searchText = "e" only first occurance not bold and everything I ned bold. Output:- diabetes I tried some code val spannable =...
  • u

    user

    06/23/2022, 3:31 PM
    open failed: EACCES (Permission denied) on Android 12, Xiaomi 11 Ultra device When one of users try to open a downloaded pdf file having this error. I am using DownloadManager to download the pdf file from url. Also I am using 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1' library as a pdf viewer. It works without a problem with all devices except Xiaomi Mi 11 Ultra. In that model device it gives the "open failed: EACCES (Permission denied)" error. Sample code below: val fileName = "${File.separator}${"Presentation_Report"}${System.currentTimeMillis()}.pdf"...
  • u

    user

    06/23/2022, 3:31 PM
    notifyDataSetChanged() is not working when observer list update data When i observe data from observer list notifyDataSetChanged() is not working help will appreciated categoryModel.mainCategoryList.observe(requireActivity()) { when (it.status) { Status.SUCCESS -> {if (it.data?.statusCode == 200) { viewBinding.shimmerViewContainer.visibility = View.GONE viewBinding.shimmerViewContainer.stopShimmer() categoryList = ArrayList()...
  • u

    user

    06/23/2022, 3:51 PM
    Add google maps to my fragment without hide my navigation bar I'm doing a kotlin app for learning purpouses but I'm pretty lost. I manage to make a main activity where to display 5 fragments in a navigation bar like this

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

    class MainActivity : AppCompatActivity() { private val mapFragment = MapsFragment() private val favoritesFragment = FavoritesFragment() private val profileFragment = ProfileFragment() private val homeFragment = HomeFragment() private val searchFragment =...
  • u

    user

    06/23/2022, 4:11 PM
    How to call findViewById(android.R.id.content) from dialogFragment? I am trying to call snack bar in dialog fragment. But it shows on top of system buttons. To avoid this I need to call findViewById(android.R.id.content) in snack bar call. But not sure how to make it correct way. In parent fragment I am calling this way Snackbar.make(requireActivity().findViewById(android.R.id.content), "fdfdfdf", Snackbar.LENGTH_LONG).show(); and it works perfectly but the problem is that dialogfragment is on top of the snack bar so its not visible. So I need to...
  • u

    user

    06/23/2022, 4:11 PM
    Snackbar crawls behind the top panel I'm trying to place a snackbar at the top of the screen, but it's crawling behind the top bar. Why is this and how can I fix it val snackBar = Snackbar.make(binding.videoPlayerBaseContainer, "test", Snackbar.LENGTH_SHORT) val view = snackBar.view val params = view.layoutParams as FrameLayout.LayoutParams params.gravity = Gravity.TOP view.layoutParams = params snackBar.animationMode = BaseTransientBottomBar.ANIMATION_MODE_FADE snackBar.show() <a...
  • u

    user

    06/23/2022, 4:11 PM
    Inheritance from an interface with '@JvmDefault' and Android Jetpack Compose navigation library I had this simple viewmodel provider factory code (taken from one of Google's code samples), which compiled perfectly... fun viewModelProviderFactoryOf( create: () -> VM ): ViewModelProvider.Factory = SimpleFactory(create) private class SimpleFactory( private val create: () -> VM ) : ViewModelProvider.Factory { override fun create(modelClass: Class): T { val vm = create() if (modelClass.isInstance(vm)) { @Suppress("UNCHECKED_CAST")...
  • u

    user

    06/23/2022, 4:31 PM
    Spring Cloud Compatibility with Spring Boot Currently the Spring Cloud documentation contains a matrix describing binary compatibility between Spring Cloud and Spring Boot. However, as Spring Boot has now jumped to 2.7.x, the matrix remains unchanged. Is there any information on how the two tracks reconcile going forward?
  • u

    user

    06/23/2022, 4:51 PM
    grouping section within itself in android list view I want to show a list as partitions in android. I have an adapter class for this and the getView() method return the cell in the section fun getView( section: Int, position: Int, convertView: View?, parent: ViewGroup? ): View { var cellView = convertView if (cellView == null) { cellView = LayoutInflater.from(context).inflate(R.layout.my_cell_layout, parent, false) //same operation } //same operation return cellView }...
  • u

    user

    06/23/2022, 4:51 PM
    How to pass selected single choice option to specific text field How can a selected option from a single choice menu be passed to a different composable to that it is displayed in a Text object? Would I need to modify the selectedOption value in some way? @Composable fun ScreenSettings(navController: NavController) { Scaffold( topBar = {...}, content = { LazyColumn(...) { item { ComposableSettingTheme() } } }, containerColor = ... ) }...
  • u

    user

    06/23/2022, 5:11 PM
    Kotlin/JS unable to create bindings for jwt-decode library So, I'm kind of new to Kotlin/JS and I'm trying to create Kotlin bindings for the jwt-decode library. Here are the Kotlin bindings I've written: /** * A Kotlin definition for the jwt-decode library's invalid token error class */ external class InvalidTokenError : Throwable /** * A Kotlin definition for the jwt-decode library's jwt decode options interface */ external interface JwtDecodeOptions { var header:...
  • u

    user

    06/23/2022, 5:31 PM
    Answering the Longest Substring Without Repeating Characters in Kotlin I've spend some time working on the problem and got this close fun lengthOfLongestSubstring(s: String): Int { var set = HashSet() var initalChar = 0 var count = 0 s.forEach {r -> while(!set.add(s[r])) set.remove(s[r]) initalChar++ set.add(s[r]) count = maxOf(count, r - initialChar + 1) } return count } I understand that a HashSet is needed to answer the...
  • u

    user

    06/23/2022, 5:31 PM
    Android app firestore issue when minify is true I am using the firestore database to store some todos and it works fine when I tried in debug + minify off. So, I create a release app and the production app was crashing continuously. The only difference between releases and debug apps are minified features and debug libs. I flipped minify to true in debug mode and got this error. Plz, help... 2022-06-23 22:36:26.123 20375-20375/sample.android.app E/AndroidRuntime: FATAL EXCEPTION: main Process: sample.android.app, PID: 20375...
  • u

    user

    06/23/2022, 5:31 PM
    Android studio XML autocomplete not working properly after converting java code into Kotlin After updating my project from java to Kotlin unable to get suggestion in XML file.
  • u

    user

    06/23/2022, 6:31 PM
    Sign In and Register Validation problem happening in Kotlin On Login page and when pressing register, it takes you to register, but when clicking on register button on register page, it adds user to database regardless if info is provided or not and then takes you back to login page, where you are able to log in regardless if email and password is even entered. I want the validation to happen before the execution. I think it executes the validation process, but still continues to insert data (even if its blank) into the database. import...
Powered by Linen
Title
u

user

06/23/2022, 6:31 PM
Sign In and Register Validation problem happening in Kotlin On Login page and when pressing register, it takes you to register, but when clicking on register button on register page, it adds user to database regardless if info is provided or not and then takes you back to login page, where you are able to log in regardless if email and password is even entered. I want the validation to happen before the execution. I think it executes the validation process, but still continues to insert data (even if its blank) into the database. import...
View count: 3