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/05/2022, 2:51 PM
    why this kotlin file named Color.kt was different after two times compiled my androidx.core library version is: androidx.core:core-ktx:1.2.0 and compile environment is: org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30 com.android.tools.build:gradle:4.2.2 gradle 7.4 jdk11 however i found some kotlin files was different in classes.dex after compiled the APK twice. the different part is: d2 order in Metadata(the order of d2 values was changed each compiled)

    enter image description hereâ–¾

    ...
  • u

    user

    07/05/2022, 2:51 PM
    request post with retrofit in android i want use request post in my app . i use this but i have problem . I face this problem when I want to create an account . status code 403 you can see my code Api.kt interface Api { @Headers("Content-Type: application/x-www-form-urlencoded") @POST("users/signup") @FormUrlEncoded fun createUser( @Field("first_name") fName: String, @Field("last_name") lName: String, @Field("email") email: String, @Field("username") username: String, @Field("password") password: String, ) :...
  • u

    user

    07/05/2022, 3:11 PM
    File contents not written I let the user create a file in my app: private val resultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { if (it.resultCode == Activity.RESULT_OK) { it.data?.data?.let { uri -> runBlocking { val outputStream = requireActivity().contentResolver.openOutputStream(uri) outputStream?.write(createCSV().toByteArray()) outputStream?.close() } } } }...
  • u

    user

    07/05/2022, 3:11 PM
    How we can get image from camera with fragment in kotlin? I search documentation and tutorial for this, but all the tutorial using activity than fragment. And when i try it, it doesn't work in fragment. Do you have any documentation, artikel, or tutorial about this? I'm trully new in kotlin. Thank you.
  • u

    user

    07/05/2022, 3:31 PM
    How to return value in coroutine scope? Is it possible to to return value in Coroutine Scope without run blocking? For now my code in repository looks like this: suspend fun getWorkItem(workItemId: Int): WorkItemRoom? { runBlocking { return@runBlocking CoroutineScope(Dispatchers.Main).launch { getWorkItemByIdUseCase.build(workItemId) } } return null } this is my useCase class GetWorkItemByIdUseCase(private val workItemDao: WorkItemDao) :...
  • u

    user

    07/05/2022, 3:51 PM
    loop showing only 2 elements out of 10 after a live data observation I am listening to an emit from a live data and want to loop through the list to Log them. if I do myList.toString(), I can see all 10 elements of the list. But my loop stops after logging two elements: myLiveData.observe(this, Observer { val items : List = it Log.i("TAG", "${items.toString()}") // shows all 10 items correctly //log each item for(i: Item in items){ Log.i("TAG", i.code) } // above loop shows the first two items only....
  • u

    user

    07/05/2022, 4:11 PM
    Change specific items in List when using DiffUtil In case, When there is a list with 100 items and wanna change only some of them, should I need to create a new list for comparison with DiffUtil? fun fetchDynamicItems() { val items = repository.fetchOnlyDynamicItems() replaceDynamicItems(items) } fun replaceDynamicItems(dynamicItems: List) { val oldList = getCurrentList() val newList = getCurrentList().map { when (it) { is DynamicItem -> dynamicItems.get(matchedIndex) else -> it }...
  • u

    user

    07/05/2022, 4:31 PM
    Hamburger Icon not showing for second time when I go to other Fragments First I have made a button navigation with three Fragments in Main Activity and I made a Hamburger Icon in Toolbar , when I run the app , hamburger icon work correctly for the first time

    first imageâ–¾

    but when I go to other fragments or comeback to home fragment, there is no hamburger icon.

    second imageâ–¾

    and here is my codes : Main Activity :...
  • u

    user

    07/05/2022, 5:11 PM
    Callback function can be changed in Compose? As I am doing this codelab (Step 4) from Android Developer website, I noticed it is said that the callback function can be changed even after it is passed to the Composable, and the code needs to protect it against changes. As below: Some side-effect APIs like <a...
  • u

    user

    07/05/2022, 7:11 PM
    Need to update textview with url everytime when webview url changes in kotlin Trying make a simple browser, and can't set a fild that will showing current webview's url. Tried override functions, but always says that "name of function" overrides nothing. Also can add that webview is within fragment. Maybe i can call this from mainactivity, but idk how. webview_fragment.kt package com.example.webviewapp import android.content.ContentValues.TAG import android.graphics.Bitmap import android.os.Bundle import android.util.Log import android.view.LayoutInflater import...
  • u

    user

    07/05/2022, 7:51 PM
    Android SSL Pining Access Specific Url Without Pining While Other Endpoints Are Pinned So I have a question. Is it possible to configure network_security_config.xml in a manner that a single specific endpoint in the domain can be accessed without pinning while every single other endpoint in the domain is enforced pinning. Example: example.com/access_without_pin and example.com/* (every other single endpoint) I want the application to be able to access example.com/access_without_pin even without pinning where as the other endpoints (example.com/getUser etc.) are enforced to be...
  • u

    user

    07/05/2022, 7:51 PM
    autocomplete for room query stopped working? After opening my room dao I noticed that the autocomplete for Query annotation does not work at all. Not only that, but it also does not check any SQL queries I try to enter for errors and spelling mistakes:

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

    ( I purposefully used "FRR" instead of "FROM" to show that the error correction does not work ) I've already tried to invalidate caches and restarting android studio, but that changed nothing. Any ideas? (also,...
  • u

    user

    07/05/2022, 8:11 PM
    Kotlin - Clipboard option missing in InputText field Compose UI Looking for help with the clipboard in Compose UI. The Edittext field is not showing clipboard option in popup (when user double tap on edittext). Case 1. It is there for normal xml screen (clipboard - on double tap on edittext field)

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

    Code : Case 2: In Compose Ui (need to long-press in inputText field and clipboard is missing here

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

    How...
  • u

    user

    07/05/2022, 8:11 PM
    Jetpack Compose Fixed Footer on a BottomSheet I'm pretty new to Compose, but I have the composable BenefitsCard Being created as such @Composable fun BenefitsCard(showDarkTheme: Boolean, listener: EliteBenefitsListener, data: List? = null) { BottomSheetWithFixedTitle( colors = huntColors, showDarkTheme = showDarkTheme, listener = listener, title = R.string.benefit_title ) { ScrollableBenefitsContent(data) } } This composable appears exactly how a I want it. I can scroll to the bottom...
  • u

    user

    07/05/2022, 8:11 PM
    Add Copy to clipboard on CardLayout Trying to add "copy to clipboard" function to CardLayout, which pulls external data in using Adapter. This is my current code: class CardLayout : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.card_layout) val activity: ImageButton = findViewById(R.id.copy) activity.setOnClickListener { // Code to Copy the content of String to the Clip board. val...
  • u

    user

    07/05/2022, 8:51 PM
    Run Kotlin script in Android Gradle task I have a script that generates a Kotlin file from an external JSON file in my project (using Kotlin Poet), under app/src/.../scripts/Script.Kt with a main() function. I want Gradle to automatically run this script during the build phase. What is the appropriate way to do this? I've tried declaring a JavaExec task like this task gen(type: JavaExec) { // sourceSets.main.runtimeClasspath does not work classpath += files("${buildDir}/tmp/kotlin-classes/debug") main = '.ScriptKt' }...
  • u

    user

    07/05/2022, 9:11 PM
    Spring Boot - Default Content Type Not Being Honored I am working on a Kotlin / Spring Boot project, and have noticed lately that direct calls to my application's REST API have returned XML-Formatted responses. For example, say I was to call localhost:8080/api/v1/config, which should return a JSON object explaining the application's configuration. Instead of JSON, I am seeing the same response, but in XML. This has not affected the Angular webapp, as OpenAPI always requests JSON in the response. However, internal integration tools would prefer...
  • u

    user

    07/05/2022, 9:11 PM
    No Pact files were found to verify I am facing weird issue for pact testing. When I use local pact-broker same test is passing however, when I use remote pact-broker test is failing. systemProperty 'pactbroker.url', 'https://pact-broker.internal-dev.com/' // Test is failing systemProperty 'pactbroker.url', 'http://localhost:9292/' // Test is passing, I have setup locally and published to it Errors: No Pact files were found to verify Provider: Provider1 Source: Pact Broker https://pact-broker.internal-dev.com/...
  • u

    user

    07/05/2022, 9:51 PM
    Spring Websocket @MessageMapping is not triggered as soon as payload size is around 30.000 characters. How can I remove this limitation? I have a big issue at the moment. While developing a Websocket communication with Spring Messaging I used no real life test data. The problem I face now is that the real world data is pretty large but I have to send it over websocket to a @MessageMapping endpoint. It seems that as soon as the payload is ~ 30.000 characters the endpoint is not triggered anymore. I already tried to increase the send limit in my WebsocketConfiguration to very large limits but it still does not work. Please take...
  • u

    user

    07/05/2022, 10:31 PM
    Getting few error while trying to implement Wifi P2P in Android using Kotlin WiFiDirectBroadcastReceiver.kt Code gist MainActivity.kt Code gist The issues are these - discovery of peers takes too long, it was working fine before I created Server Class and Client Class for sending messages When the phones get connected, this part of code doesn't seem to...
  • u

    user

    07/06/2022, 1:51 AM
    estoy intentando agregar un setBackgroundResource si el task.status es igual a 3 y position igual a 0 pero no se como no puedo agregar la taskList[position] igual a 0 y task.status = 3 y cambie el color setBackgroundResource class TaskAdapter( private var taskStatus: Task, private val context: Context, private val taskList: List, val taskSelected: (Task, Int) -> Unit, ) : RecyclerView.Adapter() { companion object { val SELECT_BACK: Int = 1 val SELECT_REMOVE: Int = 2 val SELECT_EDIT: Int = 3 val SELECT_DETAILS: Int = 4 val SELECT_NEXT: Int = 5 } override fun onCreateViewHolder(parent:...
  • u

    user

    07/06/2022, 3:11 AM
    holder.bindingAdapterPosition returns -1 binding adapter position is returning -1 and i cannot figure out why, anyone has an idea of what i could be doing wrong ? holder.bindingAdapterPosition in onCreateViewHolder. Adapter and viewHolder class CommentAdapter: RecyclerView.Adapter() { private var likeClick: LikeClick? = null private var disLikeClick: DisLikeClick? = null inner class CommentHolder(view: View) : RecyclerView.ViewHolder(view) { val nicknameTextView: TextView =...
  • u

    user

    07/06/2022, 3:11 AM
    Why Coroutine concurrency post body error I have two api using Coroutine and retorfit @POST("/api1") fun api1(@Body requestBody: Request1) @POST("/api2") fun api2(@Body requestBody: Request2) how I call fun callApi1() { GlobalScope.launch { Apiservice.api1() ... } } fun callApi2() { GlobalScope.launch { Apiservice.api2() ... } } they both work and get correct response I want but when I call them at the same time every 5 seconds fun getApi() { GlobalScope.launch {...
  • u

    user

    07/06/2022, 3:31 AM
    java.lang.RuntimeException: BindCustomDialogFragment is not annotated with Layout QUESTION IS FOR KOTLIN IN ANDROID STUDIO. I am having trouble attaching a BindCustomDialogFragment() to a recycler view. This is the fragment that I'm trying to attach: @SuppressLint("NonConstantResourceId") @FragmentLayout(R.layout.spa_new_box) class SpaNewBox : BindCustomDialogFragment() { companion object{ private var f : SpaNewBox ?= null fun dialog() : SpaNewBox { if(f !=null){ f?.dismissAllowingStateLoss() f =null...
  • u

    user

    07/06/2022, 4:31 AM
    How do I convert bitmap fto FIle in kotlin? I use Fragment This is my code : private val cameraResult = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> if (result.resultCode == Activity.RESULT_OK && result.data != null) { val bitmap = result.data?.extras?.get("data") as Bitmap binding.ivProfile.loadImage(bitmap) } } the result type is bitmap, but the required type that server needed is File. So how can i convert bitmap to File? Thankyou...
  • u

    user

    07/06/2022, 4:51 AM
    how to Web Scraping a dynamic page in android with JSOUP I am trying to web scrap this website here using JSOUP, But in this website when we put link in search bar and click search button the website dynamically load and show Some downloads links that what i want to scrap, my problem is how to load link in JSOUP with the link search without clicking search button and show result (scrap result ).Is there any way to search link and load without clicking any button and get result ??...
  • u

    user

    07/06/2022, 5:11 AM
    xml parsing using jaxb in kotlin data class I tried to parsing xml using JAXB library. I want to convert it to Kotlin dataClass. This is the original xml....
  • u

    user

    07/06/2022, 5:51 AM
    The Difference {}, () in kotlin null check I'm practicing null checking in kotlin When I use Elvis operator ?: I use {} but the correct way is using (). But My mistake, the result was wrong. My Mistake Codes are below. var name: String = "eunno"//NonNull val lastName: String? = null val fullName = name + " " + {lastName ?: "No lastName"} Result when use {} eunno Function0 Result when use () eunno No lastName I don't understand the difference of results. Is there any difference about using {}, ()?
  • u

    user

    07/06/2022, 6:11 AM
    I am looking for a way to make ScrollView scale and pan in Kotlin The question is difficult to understand due to machine translation. Sorry. I am looking for a way to make ScrollView scale and pan in Kotlin. Current status: Scrolling and scaling have been implemented. Goal: In addition to the current implementation, pan is possible when the view is zoomed in. I am just starting to learn Kotlin, so I would greatly appreciate it if you could give me more details. Here is the current code. ktfile class MainActivity : AppCompatActivity() { private var...
  • u

    user

    07/06/2022, 6:11 AM
    Starting activity with an intent in a Worker does not work on some devices I am trying to implement a Worker using WorkManager API to open an activity only once on a specific time/date when the app is in background, It does work in my emulator even on Android 12 but when I run it on my Redmi note 8 phone it does not open the activity although the workers are working normally on the same phone OpenActivityWorker.kt class OpenActivityWorker(val context: Context, private val workerParameters: WorkerParameters) : Worker(context, workerParameters) {...
Powered by Linen
Title
u

user

07/06/2022, 6:11 AM
Starting activity with an intent in a Worker does not work on some devices I am trying to implement a Worker using WorkManager API to open an activity only once on a specific time/date when the app is in background, It does work in my emulator even on Android 12 but when I run it on my Redmi note 8 phone it does not open the activity although the workers are working normally on the same phone OpenActivityWorker.kt class OpenActivityWorker(val context: Context, private val workerParameters: WorkerParameters) : Worker(context, workerParameters) {...
View count: 2