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/20/2022, 8:11 PM
    Navigating using a navigation drawer and fragments I am currently using a navigation drawer with navigation fragments, however I cant figure out how to combine the navigation drawer so that when you press one of the buttons on the navigation drawer, it navigates to the respective fragment. I have created 3 fragments already. I am trying to do this as well while using binding as well but so far without any luck. Anyone got some suggestions? This is my MainAvtivity: class MainAppActivity : AppCompatActivity() { private lateinit var...
  • u

    user

    06/20/2022, 8:31 PM
    How to save string to pdf? Do you know how to save string to pdf. I use this code and it doesn't work or it saves somewhere else. fun stringToPdf(data: String) { // val extstoragedir = Environment.getExternalStorageDirectory().toString(); val path = applicationContext.filesDir.absolutePath val extstoragedir = path val fol = File(extstoragedir, "sample.pdf"); val folder = File(fol, "pdf"); if (!folder.exists()) { val bool = folder.mkdir(); } //...
  • u

    user

    06/20/2022, 8:51 PM
    OsmDroid: User agent doesn't work with Fragments Every example available on the internet tells us to use this line of code to get the user agent (without it the map won't load). osm.osmdroid.config.Configuration.getInstance() .load(applicationContext, this.getPreferences(Context.MODE_PRIVATE)) The problem is that applicationContext yields "Unresolved reference". Same goes for this.getPreferences(). I've tried to put that code into MainActivity (no fragments) and it works. Is there any way to replace it in this context?
  • u

    user

    06/20/2022, 8:51 PM
    Saving CheckBox States When Switching Between Activities (Kotlin) I'm making an Android app in Android Studio for my girlfriend to help her keep track of her tasks at work. The app has multiple to-do lists using RecyclerView. Since each checklist has their own activity, and she will be switching between them, how do I save which boxes have been checked so that they remained checked when switching between activities? Here is the RecyclerView adapter code for one of the to-do lists that also contains the Checkbox code. package com.mattkalichman.coffee import...
  • u

    user

    06/20/2022, 8:51 PM
    Class does not show override methods from inheritance class I have created class ScreenDrawer that has 3 functions. And I have a class ChatsScreen that inherits the ScreenDrawer. But for some reason when I click Ctrl+O in Android Studio I don't see methods that I can override as I can do in MainActivity that extends AppCompatActivity. So how I need to organize classes so my ChatsScreen could see ScreenDrawer methods by inherit it. Here is my ChatsScreen

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

    Here is my...
  • u

    user

    06/20/2022, 9:11 PM
    ANDROID STUDIO BLE: How do I add the LeDeviceListAdapter class to my BLE project? I am new to Android Studio and to BLE. I am working on a program that will scan for a beacon to read information. I am following this tutorial and the closest solution to my problem I found so far was this post. I am trying to get my app to respond to...
  • u

    user

    06/20/2022, 9:51 PM
    Equals() between objects of inconvertible types SQLite Android in all my insertData methods im getting this warning fun insertDataOwnerTable(nickname: String, ownername: String, ownersPhone: String, pin: Int, dateSignup: String, country: String, ownersMail: String): Boolean { val db = this.writableDatabase val cv = ContentValues() cv.put(NICKNAME_COL, nickname) cv.put(NAME_COL, ownername) cv.put(PHONE_COL, ownersPhone) cv.put(USER_PIN, pin) cv.put(DATE_SIGNUP, dateSignup)...
  • u

    user

    06/20/2022, 11:51 PM
    RecyclerView and OnItemClick: No value passed for parameter 'click' in Fragment I'm trying to implement an OnClick listener for specific items in a recyclerview. I've done it before with activities, but now I want to do this in a fragment and I've run into a problem. I'm getting the error No value passed for parameter 'click'. This is the line of code that gives that error: recyclerAdapterAbstract = abstractList.let {AbstractAdapter(requireActivity(),it)} This the only error Android Studio is currently showing me. The logcat doesn't show any error. Only the Build Output...
  • u

    user

    06/21/2022, 12:51 AM
    why is my android studio showing Unresolved reference: ExpressionBuilder:49?

    Gradle project sync failed, Basic functionality will not work properly.â–¾

  • u

    user

    06/21/2022, 3:11 AM
    Installing SDK (Java) in flutter APP MainActivity.kt I am a new bee to coding. I am getting an error while Initialise the SDK in my app Application file as @Override public void onCreate() { super.onCreate(); Cuelinks.initialize(this); } the error is : * What went wrong: Execution failed for task ':app:compileReleaseKotlin'.
    Compilation error. See log for more details
    My app is a flutter app. I need to paste the above code in MainActivity.kt I would be very thankful if I get any solution. Please help
  • u

    user

    06/21/2022, 6:31 AM
    Kotlin String.split().filterIndexed() is returning empty list with size 1 fun main() { val delDetails = "2-hello,3-world,4-why,5-is,6-it,7-like,8-this" val delDetailEmpty = "" val delPositions = delDetailEmpty.split("-",",").filterIndexed { index, _ -> index % 2 ==0}.toMutableList() println(delPositions.size) //it returns empty list [] with size 1 println(delDetailEmpty.toList().size) //this returns empty list [] with size 0 } println(delPositions.size) returns empty list [] with size 1 whereas, println(delDetailEmpty.toList().size) this returns empty list []...
  • u

    user

    06/21/2022, 6:31 AM
    When will Jetpack Compose launch recomposition and what will be recomposition.? I was told "You need to create scopes if you need to have scoped recompositions" by Thracian in the question. It seems that I can't find the policy from official documnet. The Code A is based the answer of Thracian. I get Result A when I run Code A. 1: When will MyColumn(Calendar.getInstance().time.toSeconds()) be launched ? 2: Why is CallMyColumn()...
  • u

    user

    06/21/2022, 6:51 AM
    kapt.use.worker.api is deprecated After build I get this warning: 'kapt.use.worker.api' is deprecated and scheduled to be removed in Kotlin 1.8 release. Knowing that I have in my gradle.properties : kapt.use.worker.api=true and in my Module level build.gradle : apply plugin: 'kotlin-kapt' then, what is the alternative to the deprecated line ?
  • u

    user

    06/21/2022, 7:11 AM
    easy way to flag library functions as deprecated / forbidden in android studio I have a mixed Java / Kotlin project in Android studio with the usual bunch of androix libraries. Is there an easy way (short of writing custom lint/detekt/ktlint rules) to essentially deprecate certain usages of third party libraries? Assuming I have no way of actually changing the code in the library itself. For example, the library has a method foo, I'd like all usages of that method to be flagged and break the build.
  • u

    user

    06/21/2022, 7:31 AM
    Kotlin shuffle a list and validate list value with user value I have a list that holds string values as directions, for each time is started is shuffle the list val directions = mutableListOf("left","right","up","down") directions.shuffle() I am running a continuous loop to check if the percentage value has grown to a certain point before breaking the loop if(progress != 100){ //continue until progress is 100 } I send the instructions to the user and if they match the progress value increases when(directions){ "left" -> { // print...
  • u

    user

    06/21/2022, 7:51 AM
    How to change "val" values in an object withotu changing the definition to "var"? I have a complex Kotlin data class, say something like this: data class Post( val message: Message, val dateAndTime: LocalTime, val postAuthor: Author?, val visitorsVisitedTimes: List ) and each of Message, LocalTime, ... are different data classes. I have an object of above Post data class. I want to parse it, access visitorsVisitedTimes field value, for each pair, replace Author object with corresponding postAuthor. I have to make similar changes in the Message object as...
  • u

    user

    06/21/2022, 8:11 AM
    My Exo player not working with youtube url? I used Youtube extractor library https://github.com/HaarigerHarald/android-youtubeExtractor it is showing java.io.FileNotFoundException: <a href="https://www.youtube.com/get_video_info?video_id=TNAMFEo07PU&amp;eurl=https%3A%2F%2Fyoutube.googleapis.com%2Fv%2FTNAMFEo07PU" rel="nofollow...
  • u

    user

    06/21/2022, 8:11 AM
    Compose deep link is causing my view model data to be empty I am working on a project that uses jetpack compose and whenever i load a composable through deep links, any data that gets loaded quickly appears then goes missing. my deep link is pretty straight forward composable( DestinationScreen.Screen.route + "/{index}", arguments = listOf(navArgument("index") { type = NavType.StringType }), deepLinks = listOf(navDeepLink { uriPattern ="pattern/job/{index}" }) ) { entry ->...
  • u

    user

    06/21/2022, 8:11 AM
    kotlin findViewById returns null I have the following code which after clicking on the button findViewById returns null but when I set the onclick attribute of the picture itself to change the picture there is no null exception returned. This code returns null exception: private lateinit var imageView1: ImageView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) } fun change(view: View){ try { imageView1 =...
  • u

    user

    06/21/2022, 8:11 AM
    Destructuring declaration initializer of type Array&lt;String?&gt; must have a 'component6()' function in Kotlin I am having one issue in Destructuring in kotlin. I am doing one functionality in A/B Testing. Previously this was in if-else case and that time it works fine. Now moved it to Kotlin file and when i am trying to add 6th params(need to add more params) I am getting the error "Destructuring declaration initializer of type Array must have a 'component6()' function". I am pasting my code here, Could anyone please help me to resolve this error. class SampleRepository( private val...
  • u

    user

    06/21/2022, 8:31 AM
    How to get the current time using Event Channel? I need to get current time using Event Channel.Receive on button click. I don't understand how to write code in kotlin file. How can I get the current time using Event Channel? I have attached the Flutter code and kotlin file below. class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @override State createState() => _HomePageState(); } class _HomePageState extends State { static const EventChannel _eventPlatform =...
  • u

    user

    06/21/2022, 8:31 AM
    How can I search data from firebase using searchview in kotlin? I need some help about add search view to android studio kotlin project and it related to Firebase Firestore
  • u

    user

    06/21/2022, 8:51 AM
    Android - How to make a pop up message notification like this?

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

    The pop up message is the Green one. I tried to use snackbar but many says Snackbar cant make custom layout and Toast doesnt have an action. So what should I use to make that green pop up message?
  • u

    user

    06/21/2022, 9:11 AM
    Logging in FlutterActivity not appearing in VS Code I'm developing a Flutter app, using VS Code. I've added some logging to my FlutterActivity, as follows: package com.example.package import android.os.Bundle import android.util.Log import io.flutter.embedding.android.FlutterActivity class MainActivity: FlutterActivity() { val TAG = this.javaClass.name override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) Log.d(TAG, "Hello World!") } //... When I run my app, I expect to see...
  • u

    user

    06/21/2022, 9:51 AM
    create objects based on elements of a list Suppose I have the below lists and data classes in Kotlin: val qrtr = listOf("Q1", "Q2", "Q3", "Q4") data class X(val name: String, val location: String) val x1 = X("John Doe", "USA") val x2 = X("Jane Doe", "Singapore") val allX = listOf(x1, x2) data class Y(val title: String, val rating: Double) val y1 = Y("Senior", 4.8) val y2 = Y("Junior", 4.5) val allY = listOf(y1, y2) Is there an easy way to create another list using a 3rd data class using the above lists of allX, allY and qrtr. data...
  • u

    user

    06/21/2022, 9:51 AM
    How to add spaces between numbers with Kotlin How can I convert Float into a format like "2 000 000.00 USD" with Kotlin?
  • u

    user

    06/21/2022, 10:31 AM
    Please help me find errors in this small piece of code I am into Android Development. I don't know Kotlin just Java but had to submit a project in Kotlin so I wrote the code in Java and Used the inbuilt "Convert Java code to Kotlin Code" feature of Android Studio. But the converted code has some errors, I don't know how to solve them. Heres the code: package com.varunsen.newcards import android.os.Bundle import android.view.View import android.widget.ArrayAdapter import android.widget.ListView import android.widget.TextView import...
  • u

    user

    06/21/2022, 10:51 AM
    Error executing DDL "create table users (...)" via JDBC Statement I am trying to learn how to use the H2 database in my Spring Boot application but am running into trouble with respect to creating a table representing the defined entity located in User.kt. Seemingly the table creation fails and as such the data insertion from data.sql reasonably so also fails. I don't understand what I am doing wrong. I am not sure if it's relevant or not but I have googled around for a while to try and solve this and came across some comment or two somewhere saying...
  • u

    user

    06/21/2022, 10:51 AM
    Multithreading - working with threads in Kotlin I am currently studying the basins and want to understand the work with multithreading, but I can not understand the task Calculate f (x) * g (x) using 2 auxiliary threads: one calculates f (x) and the other g (x). The main program performs I / O and operation *. Note that the functions f and g - can be partially defined (ie "loop" and never return the result). It is necessary to process such situation correctly and to ask the user: "to continue calculation, to stop or to continue, without...
  • u

    user

    06/21/2022, 11:11 AM
    PRDdownloader not starting after pressing download button. Kotlin I followed a tutorial on YouTube on how to download FirebaseRealtime Database files to local storage using PRDownloader. However I've run into a problem, which is when the download button is clicked nothing happens. Code for downloading override fun onItemClick(item: String, position:Int) { abstractData = item positionItem = position if (checkSelfPermission(requireActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED ){...
Powered by Linen
Title
u

user

06/21/2022, 11:11 AM
PRDdownloader not starting after pressing download button. Kotlin I followed a tutorial on YouTube on how to download FirebaseRealtime Database files to local storage using PRDownloader. However I've run into a problem, which is when the download button is clicked nothing happens. Code for downloading override fun onItemClick(item: String, position:Int) { abstractData = item positionItem = position if (checkSelfPermission(requireActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED ){...
View count: 8