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/24/2022, 10:11 AM
    How to make Compose Text wrap container size I have some Column with Icon and Text inside. Column is wrap the size of Text but i want to Column wrap Icon and long text move to another line

    How It's looks nowâ–¾

    How I want it to look likeâ–¾

    @Composable fun ServiceItem( service: Service, onItemClick: (service: Service) -> Unit ) { Column( verticalArrangement =...
  • u

    user

    06/24/2022, 10:11 AM
    Android can't change height of constraint layout in post I am trying to change the height of the ContraintLayout inside the post block. like so: class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) changeHeight() } private fun changeHeight() { val layoutView = findViewById(R.id.block1) layoutView?.post { Log.d("222", "1===========") layoutView.run {...
  • u

    user

    06/24/2022, 10:11 AM
    Calculate project total min coast based on the bid amount given by developer for each project : Interview Question Calculate project total min coast based on the bid amount given by the developer for each project If there is no kind of bid placed for any project then return -1, This means, there must be at least 1 bid for each project or return of -1. Output For Project 0 : Comparing bid amount of Dollar 8 with Dollar 100 For Project 1 : Comparing bid amount of Dollar 35 with Dollar 20 For Project 2 : Comparing bid amount of Dollar 10 with Dollar 25 Min cost for All projects is 38...
  • u

    user

    06/24/2022, 10:31 AM
    How to enable TextView click if one of few EditText fields changed I have tree EditText with default value and button "Save". By default my button is disabled (grey, not clickable), but when I set onCLickListener on button it became active straightaway. It should become active if at least one of these fields is changed. I don't know how to do it better, maybe through Boolean variable? Now I only can disable button in TextWatchers for editTexts: val textWatcher = object : TextWatcher { override fun afterTextChanged(et: Editable?) { when {...
  • u

    user

    06/24/2022, 10:31 AM
    Kotlin: How to define a variable whose type depends on the input? I have a function in Kotlin which takes a particular string as input. Depending on the input, I want to create a variable of a specific type and do some computations on it. For example, fun compute(input: String): Any{ if(input=="2d"){ var point: Point2D;// Points2D - x: int, y: int //initilize and do some computations return point.findDistanceFromOrigin() }else if(input=="2d-1"){ var point: Point2DWithP1AsOrigin;// Point2DWithP1AsOrigin - x: int, y:...
  • u

    user

    06/24/2022, 10:31 AM
    Multiple work request in Work Manager for Periodic task I have a task to synchronize Room DB data to the server every 2 hours in the background, for that the best option I found is Work Manager, but there is a problem I have two tables one for images and the second for the form data, first Worker Task is to upload all the images to the server using Retrofit Multipart and then upload form data from another table. There are basically need two worker classes and I don't know to arrange them to complete the whole task. Thanks in advance.
  • u

    user

    06/24/2022, 10:51 AM
    DiffUtill not redraw item in Kotlin Hey I am working diffutil with kotlin Listadapter. I want to redraw item when list is update, but item is update and it's not redrawing object. I am using kotlin flow list. I tried every piece of code from this post, but nothing working on my solution. activity.kt class ExploreActivity : AppCompatActivity() { private val binding by lazy { ExploreLayoutBinding.inflate(layoutInflater) } var exploreAdapter = ExploreAdapter()...
  • u

    user

    06/24/2022, 11:11 AM
    Could not resolve all files for configuration ':app:debugCompileClasspath'. using Android Studio Chipmunk | 2021.2.1 I have recorded a video using mobile camera but now i want to trim that video using a library, after adding the below dependency for trimming feature. implementation 'com.github.a914-gowtham:android-video-trimmer:1.7.0' i am getting this error: Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugCompileClasspath'. <a href="

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

    " rel="nofollow...
  • u

    user

    06/24/2022, 11:31 AM
    camera x is not zooming out in kotlin using seekbar val x: Float = binding.btnCameraView.getScaleX() val y: Float = binding.btnCameraView.getScaleY() /// camera is just zooming in not zoom out binding.zoomSeekbar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { cameraControl?.setLinearZoom(progress / 100.toFloat()) ///// if i donot use this binding.btnCameraView.setScaleX((x + 0.5f) as Float)...
  • u

    user

    06/24/2022, 11:31 AM
    Reset/clear adapter then regenerate with new data I have a calendar adapter that provides me the list for the days of a specific month and this month is changeable by pressing a left/right button. By default, the month is set based on the user's timezone. Question: How do I clear/reset the adapter I called for the initialized list and give it a new value of month that it needs? Or there is a better logic move here? I'm still new to Android Development. <a href="https://i.stack.imgur.com/9CaYT.gif" rel="nofollow noreferrer">Preview of my...
  • u

    user

    06/24/2022, 11:51 AM
    Jetpack Paging 3.0 with Airbnb/epoxy only load the first page I am trying to use Jetpack Paging 3.0 to get all the characters in Rick and Morty API using retrofit and display it using Airbnb/epoxy. But I only get the first page I've spent several hours trying to look for a solution but no luck. Link to API (Rick and Morty API) CODE: 1 Retrofit...
  • u

    user

    06/24/2022, 11:51 AM
    Kotlin multiplatform JS build doesn't run on IE Kotlin multiplatform uses \u escape sequence in RegEx which makes it impossible to run the app with IE
  • u

    user

    06/24/2022, 12:11 PM
    Alarm Manager cancel alarm not work correctly(After Reboot) I cancel my alarm, it's work(notification stop to arriving), but when I reboot my phone, service restart and notification arriving instead I cancel it. In manifest : android:name="android.intent.action.BOOT_COMPLETED", and uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" AlarmService class AlarmService(private val context : Context) { private val alarmManager: AlarmManager? = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager? fun...
  • u

    user

    06/24/2022, 12:11 PM
    How can I get the custom spinner here? I want to get the custom spinner look in the picture, but I couldn't. I did a lot of research but couldn't find anything like this. If you have any ideas, please write. If this issue exists, please let me know instead of downvoting.

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

  • u

    user

    06/24/2022, 12:11 PM
    JSCH - Authentication fails with valid SSH private key I'm trying to establish an SSH connection using Kotlin + JSch, but it fails with com.jcraft.jsch.jSchException: Auth fail. Steps taken: Generate ssh key pair using ssh-keygen -t rsa -m PEM (OpenSSH version: OpenSSH_8.2p1) Append contents of generated id_rsa.pub to /home/username/.ssh/authorized_keys file on the server Test connection in the terminal: ssh -i /path/to/id_rsa username@example.host.com - works fine Execute the following Kotlin code: import com.jcraft.jsch.JSch const val USER =...
  • u

    user

    06/24/2022, 12:31 PM
    Are you tired of writing lots of try and catch blocks in android? here is a solution the solution is to write an inline function with a lambda type parameter the takes a unit , which can be any kind of code you write , and put it inside a try-catch block. now you just call it and write your intended code inside it.

    this is a sample code of what I meanâ–¾

  • u

    user

    06/24/2022, 12:51 PM
    Graphql get direct requested model I implemented a sample of Graphql by Retrofit. I have a response like this: if (response.isSuccessful) { Log.e("response", response.body().toString()) Also, this is my interface class: suspend fun postDynamicQuery(@Body body: String): Response Now I want to change my method by giving a direct model. this is the servers' answer. { "data": { "getCityByName": { "id": "112931", "name": "Tehran", "country": "IR", "coord": {...
  • u

    user

    06/24/2022, 12:51 PM
    How to use multiple accounts in Firebase Auth in Android? How to use multiple accounts in Firebase Auth in Android? Using a single account works fine. But, when I try logging in with another account, the previous data is gone. How can this be done?
  • u

    user

    06/24/2022, 1:11 PM
    Receiving nullable response with RestTemplate I have a REST endpoint that returns certain object or 202 Accepted with empty response entity. How can I process both cases with rest template? getForEntity(url, MyClass) or exchange(... MyClass) throws null pointer exception when gets 202.
  • u

    user

    06/24/2022, 1:11 PM
    How can I get the package name of data copied to clipboard? I need to get package name of data copied to clipboard. For example, I just want to use copied data from com.example.customApp. So is it possible to can that? If possible, how can I do this? Thanks for helps.
  • u

    user

    06/24/2022, 1:11 PM
    How to change return type based on a function input which is a class name? I have multiple data classes and each class has a corresponding class containing more info. I want to write a function in which I should be able to pass an identifier (table name corresponding to the data class). Based on this identifier, object of the corresponding class should be made, the value changed and this object should be returned as output of the function. I have written a simplified version of it on playground but I am unable to get it to work. Any help is appreciated. class...
  • u

    user

    06/24/2022, 1:51 PM
    Minecraft Forge Registry Object not present I try to register a simple block to my forge mod. I am following the 1.18.1

    tutorial of Kaupenjoeâ–¾

    , but I am using KotlinForForge. This is my code of ModBlocks class: object ModBlocks { private val REGISTRY: DeferredRegister = DeferredRegister.create(ForgeRegistries.BLOCKS, FifiMod.MOD_ID) // Blocks val BISMUTH_ORE by...
  • u

    user

    06/24/2022, 1:51 PM
    aws android initialization error | how to initialize Getting error when trying to update version https://search.maven.org/artifact/com.amazonaws/aws-android-sdk-auth-userpools val initializeBuilder = AWSMobileClient.getInstance().initialize(activity) { createAwsSessionComponent(environment, configuration) doAfter.run() } initializeBuilder.awsConfiguration(configuration) initializeBuilder.execute()...
  • u

    user

    06/24/2022, 2:11 PM
    Is it possible to add two numbers whose power is the iterator in for loop in Kotlin without using power function Programming Language: KOTLIN I'm trying to make a function which adds two numbers in the following way.. a^i+b^i where "i" would be the iterator in for loop. So I want the i to range from 1 to 10 and print the result one by one like this... for example if I give the values as a=1 & b=2 then the result must be calculated as.. a^1+b^1= 1^1+2^1 which gives 3 so print the result. a^2+b^2= 1^2+2^2 which gives 6 and print the result. etc., repeating the process until i becomes 10. so I tried the...
  • u

    user

    06/24/2022, 2:11 PM
    Combining two flows of paging data before showing in UI I have this recycler view that shows paginated data with a PagingDataAdapter. It works well when making a single request to the service but I sometimes need to make two requests to get old and new events and show both in my recycler view. Is there a way I can combine the two flows of paginated data before showing them to the user? As it is, if I make the two requests, only the last one remains because of the invalidate() in the submitData method. This is the current implementation that...
  • u

    user

    06/24/2022, 2:11 PM
    Why does Hibernate Validator ignore my custom annotations when written in Kotlin? In a Kotlin project I am trying to get some Springboot Configuration properties JSR303 validated. Some custom validations seem to be necessary for me: @Validated @ConfigurationProperties("dtn") class ExecutableAdapterConfiguration { @FileFound //
  • u

    user

    06/24/2022, 2:31 PM
    Convert Base64 to PNG-File and save on Ktor Backende I need to save an image from the Client App as PNG on the Backend. Im sending the Image as Base64 with Post to the Backend. I cant find a way to convert the Base64 String to an PNG File and dont know, how I could save them as File on the Server. Thats the function I use to get the Data from the client. In val picture I get the Image as Base64. fun savepicture(data: getpicture) = transaction { val userid= data.userid val date = data.date val time =...
  • u

    user

    06/24/2022, 2:51 PM
    Why do I keep getting this null pointer exception android app kotlin My app was working fine, then all of a sudden, I started getting these null pointer errors. For some reason the alarm object is not being retrieved by the code. var alarm = alarmRepository.getAlarm(intentAlarmId.toLong()) I have no idea why. Even if I replace intentAlarmId.toLong() with a 1, it will still not retrieve it. So it is not that. It takes an intent extra containing the alarm id, and gets it from the room database. I have narrowed it down to the alarm object being null. I just don't...
  • u

    user

    06/24/2022, 3:11 PM
    Kotlin vs Java for Android [closed] Which programming language is easier to implement ?. I am in my holidays now. I had planned to take some courses to learn about android app development. By searching from internet i found that there are courses available with two languages java and kotlin. I know some basics in java. And now im confused with taking which course.
  • u

    user

    06/24/2022, 3:31 PM
    How to solve RecyclerView.Adapter issue? I am trying to change first text(position = 0) gravity from List in 'onBindViewHolder(viewHolder: ViewHolder, position: Int)', but, except for the first, the gravity of some elements changes. Could you tell me where this problem comes from? You can see code below and also logs class ButtonsListAdapter(private val dataSet: List) : RecyclerView.Adapter() { class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { val textView: TextView val divider: View...
Powered by Linen
Title
u

user

06/24/2022, 3:31 PM
How to solve RecyclerView.Adapter issue? I am trying to change first text(position = 0) gravity from List in 'onBindViewHolder(viewHolder: ViewHolder, position: Int)', but, except for the first, the gravity of some elements changes. Could you tell me where this problem comes from? You can see code below and also logs class ButtonsListAdapter(private val dataSet: List) : RecyclerView.Adapter() { class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { val textView: TextView val divider: View...
View count: 5