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
android
  • n

    Nikola Milovic

    06/07/2020, 9:16 AM
    Size size = cameraSource.getPreviewSize();
    getPreviewSize is is unresolved, it's the OCRReader sample from google
    cameraSource
    only has get flash,focus and facing, no parameters or size
    r
    • 2
    • 1
  • k

    Kulwinder Singh

    06/08/2020, 10:12 AM
    How much performance impact
    copy
    function of
    data
    class have if called many times ?? for example i have
    data class Position(val x:Float,val y:Float)
    and i'm doing
    copy
    of this class's instance inside android's touch listener when user's finger is moved(ACTION_MOVE) like ->
    var position = Position(0f, 0f)
    view.setOnTouchListener { v, event ->
        when (event.action){
            MotionEvent.ACTION_DOWN -> /**/
            MotionEvent.ACTION_MOVE -> {
                position = position.copy(x =computedX,y=computedY)//how much performance impact of this ??
            }
        }
    
    }
    i don't want to use mutable properties for data class for some reasons
    g
    r
    • 3
    • 20
  • s

    Shawn Witte

    06/09/2020, 1:40 AM
    Hey everyone, I'm looking for some advice on the best way to do something with coroutines. I've got a service that I need to produce data at a certain interval. Only the most recent data is relevant (e.g. elapsed time, etc.). I have a view that binds to this service that I would like to update either whenever the data is updated or possibly at a slightly longer interval. I'm wondering how people would implement this via coroutines. I'm thinking a service-scoped coroutine that looks like
    while(true) {
        delay(interval)
        updateDataObject()
    }
    Then I'm thinking of launching a coroutine in my ViewModel that looks the same except it's pulling the data out of the binding after each interval instead of generating it. Is there a better way with Channels or Flow? Or is this a reasonable approach?
    r
    k
    p
    • 4
    • 8
  • t

    TarunY

    06/09/2020, 9:25 AM
    Hello Everyone, Leakcanary gives me the log as below. can please some one suggest me to resolve this
    k
    • 2
    • 8
  • p

    pascalchidi

    06/09/2020, 7:47 PM
    How important is Viewbinding to Activity? Since i can make reference to my widgets just by importing the layout. I think Binding works better for Fragments. Any opinions ?
    o
    z
    +2
    • 5
    • 8
  • m

    Mark

    06/10/2020, 7:16 AM
    Is this a good strategy for doing some work in viewmodel and mid-way requesting a user-selection (using some dialog) before continuing to complete work? Note: using an
    Event
    wrapper since dialog is persisted through configuration changes when using navigation component. The view layer would be responsible for `complete`ing the deferrable when the user clicks an item.
    val itemSelectorLiveData = MutableLiveData<Event<Pair<List<String>, CompletableDeferred<String>>>>()
    
    suspend fun doSomethingFunButWorthwhile(): Boolean {
        val items: List<String> = workOutWhichItemsToChooseFrom()
        val deferredItem = CompletableDeferred<String>()
        itemSelectorLiveData.postValue(Event(Pair(items, deferredItem)))
        // wait for user to select item
        val selectedItem = deferredItem.await()
        return doSomethingWorthwhile(selectedItem)
    }
    a
    • 2
    • 16
  • j

    Jamie Craane

    06/10/2020, 10:23 AM
    I am writing an example app which implements a DocumentsProvider to share files with other apps using the SAF framework. The code can be found here: https://github.com/jcraane/DocumentsProviderExample I have a problem sharing the selected file with for example Gmail. Depending on the method I use in openDocument https://github.com/jcraane/DocumentsProviderExample/blob/4fe4f9fd8f48ab397b0f9d7bdfa9018dd60ddf77/app/src/main/java/nl/jcraane/myapplication/provider/SimulateNetworkDocumentsProvider.kt#L42 I get various results (see the code in the above link). In summary: - When I read in the contents of a file and return
    ParcelFileDescriptor.open(file, ParcelFileDescriptor.parseMode(mode))
    it works from Gmail. This is using the readFilesUsingOpenDocumment() function. - When I read in the contents and use createReliablePipe, I can get the contents in the sample app but not in Gmail., which gives the following exception:
    2020-06-10 09:15:31.643 14097-14235/nl.jcraane.myapplication E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
        Process: nl.jcraane.myapplication, PID: 14097
         Caused by: java.io.IOException: write failed: EPIPE (Broken pipe)
    This is using the readFileUsingReliablePipe() function. - When I use createReliablePipe and I do not use a ASyncTask, the app hangs when large amounts (more than a couple of Kb) of data are transferred. Does anyone have more insights in how openDocument should be implemented? Ideally I also want to download files via a URL and stream the bytes back when the download is finished. Is there a possibility of letting the calling app know a download is in progress (to show a progress bar)? How should createReliablePipe be used correctly? Thanks!
    • 1
    • 2
  • a

    Anastasia Finogenova

    06/10/2020, 1:08 PM
    Hi everyone a question, I don't think it is mentioned in the docs anywhere. When overriding ViewModel's onCleared is calling super.onCleared() required and what are possible consequences of not calling it , does anyone know?
    g
    z
    i
    • 4
    • 9
  • m

    Matti MK

    06/10/2020, 4:28 PM
    Anyone have a pointer on how to run multiple motionlayout transitions sequentially? I.e. after first one ends, trigger second one
    d
    j
    • 3
    • 10
  • e

    Erik

    06/10/2020, 9:44 PM
    I'll just leave this here in case you've missed it, but it looks pretty new to me! https://dagger.dev/hilt
    💯 2
    r
    j
    +5
    • 8
    • 17
  • j

    Javier

    06/10/2020, 9:45 PM
    Anyone is having problems with buildSrc (kts files) and the new AGP 4.2 plugin?
    l
    • 2
    • 22
  • k

    krtko

    06/11/2020, 5:07 AM
    I'm mostly doing iOS developement at my job these days, but I would kill for just a fraction of the quality tools Android developers get. The Android Dev team had been killing it, good job y'all.
    ❤️ 6
    ☝️ 6
    t
    m
    • 3
    • 10
  • s

    Saurabh Thorat

    06/11/2020, 7:33 PM
    What do you guys think about Gradle Kotlin DSL migration? The last time I tried it a few months ago, it wasn’t worth the hassle. IDE support wasn’t that great then, I needed additional plugins to check dependency updates and it was lacking good documentation. But now it seems Google has started using it in their I/O 2020 app. Makes me want to try it again.
    d
    b
    +4
    • 7
    • 7
  • a

    allan.conda

    06/12/2020, 4:51 AM
    anyone know how to fix this warning?
    /.gradle/caches/transforms-2/files-2.1/08b4d730ba6c80c87328a0558e314dae/jetified-kotlin-stdlib-jdk7-1.3.72.jar: Runtime JAR file has version 1.3 which is older than required for API version 1.4
    j
    i
    l
    • 4
    • 12
  • s

    Samyak Jain

    06/12/2020, 8:36 AM
    tasks {
        withType<KotlinCompile> {
            kotlinOptions.jdkHome = rootProject.extra["JDK_18"] as String
            kotlinOptions.languageVersion = "1.2"
            kotlinOptions.apiVersion = "1.2"
            kotlinOptions.freeCompilerArgs += listOf("-Xskip-metadata-version-check")
        }
    
        named<ProcessResources>("processResources") {
            val propertiesToExpand = mapOf("projectVersion" to project.version)
            for ((name, value) in propertiesToExpand) {
                inputs.property(name, value)
            }
            filesMatching("project.properties") {
                expand("projectVersion" to project.version)
            }
        }
    
        named<Jar>("jar") {
            callGroovy("manifestAttributes", manifest, project)
        }
    
        named<ValidateTaskProperties>("validateTaskProperties") {
            failOnWarning = true
        }
    
        named<DokkaTask>("dokka") {
            outputFormat = "markdown"
            includes = listOf("$projectDir/Module.md")
        }
    }
    g
    • 2
    • 5
  • l

    Lilly

    06/12/2020, 3:40 PM
    Does someone know where I can find the release notes for the android gradle plugin version 4.2.0-alpha01. I have a buildSrc folder and since I updated to this version the task
    :buildSrc:generatePrecompiledScriptPluginAccessors
    fails with the message "Caused by: org.gradle.api.plugins.InvalidPluginException: An exception occurred applying plugin request [id: 'android']" and a lot of other errors. I'm using AS 4.2 C1, when I switch AGP back to version 4.1.0-beta01 it runs the task properly. Are there any breaking changes in the new AGP version?
    j
    • 2
    • 6
  • l

    Lilly

    06/12/2020, 9:24 PM
    Did someone notice that
    Scaffold(bodyContent = { // code here is called twice })
    is called twice? I'm using dev13 but same problem with dev12. I can't test the other versions because my project fails otherwise. EDIT: sorry wrong channel.
    j
    • 2
    • 4
  • m

    Mohamed Ibrahim

    06/12/2020, 10:10 PM
    is there any JSONAPI plugin to generate Kotlin data classes from JSON?
    b
    • 2
    • 3
  • g

    gauravm8

    06/13/2020, 6:56 AM
    Have a great day everyone....what are you all planning to catchup on weekend? Mine is Hilt 😄
    m
    s
    • 3
    • 3
  • a

    Akram

    06/13/2020, 8:49 PM
    Hello, I'm just starting with motion layout and I'm trying to run transition from the kotlin code, I have tried the
    transitionToEnd()
    but it is acting weirdly any help?
    h
    • 2
    • 1
  • t

    The Birdwatcher

    06/14/2020, 1:09 AM
    Hi all. Any leads of kotlin backend grpc built in gcp using microservices is highly appreciated. Our lead is unwell and went for a forced sabbatical and we could use a talent engineer to support or fully lead remotely. Its b2b app with kotlin native mobile and angular web app. Thank you in advance and have a great weekend.
    r
    • 2
    • 4
  • v

    vesp

    06/14/2020, 9:00 AM
    Does anyone have reccomendations on repos I should keep an eye on for up to date Android best practices or just general learning? When I was in school, I used this this repo to learn all about dagger2, rxjava and clean architecture. Maybe someone else might have a good suggestion with more jetpack stuff. I'm aware of the codelabs and use that for reference but there's something about a full project and seeing all the moving parts that make reading much more compelling.
    h
    j
    • 3
    • 5
  • s

    Sandesh Baliga

    06/14/2020, 1:08 PM
    I'm using a ListAdapter for one of my projects. And i noticed that submitting a large list of items adapter.submitList(200+ items), is blocking the UI thread. Diffutil calculation was supposed to happen in background thread according to documentation. I'm confused what's happening. Am I missing something?
    s
    j
    • 3
    • 25
  • h

    haroldadmin

    06/15/2020, 6:20 AM
    Hey. Would someone like to help me by reviewing a blog post of mine on the internals of the Jetpack App Startup library?
    s
    • 2
    • 3
  • t

    TarunY

    06/15/2020, 8:14 AM
    Hi All, i am trying to integrate opencv-4.3.0 with my existing android app. after importing opencv module i am getting an error. please suggest me to solve below error:
    :stackoverflow: 3
    t
    • 2
    • 2
  • k

    Kamil Kalisz

    06/15/2020, 8:21 AM
    HI All, Do you know if there is any API to get your application price from google play?
    :google: 2
    a
    • 2
    • 2
  • n

    Nikhil Soni

    06/15/2020, 11:09 AM
    Hey there, I am new to Android development and getting difficulties in learning things.. can anyone help me giving some tips regarding how to study productively and learn as much as possible ? and also some good resources to learn from?
    w
    z
    +3
    • 6
    • 8
  • k

    Kaushik

    06/15/2020, 11:32 AM
    I should give feedback in the app it will automatically post in the play store review page.
    s
    r
    • 3
    • 2
  • l

    luke_c

    06/15/2020, 9:53 PM
    Is there any practical difference between @ActivityScoped and @Singeton in Dagger Hilt in a single activity application?
    j
    • 2
    • 3
  • a

    Attila Blenesi

    06/16/2020, 12:06 PM
    Hello, 👋 Is there a way to identify extended grapheme clusters? 👩‍👩‍👧‍👧 👍🏽 <- My use case is detecting first user perceived character in a String
    r
    g
    • 3
    • 11
Powered by Linen
Title
a

Attila Blenesi

06/16/2020, 12:06 PM
Hello, 👋 Is there a way to identify extended grapheme clusters? 👩‍👩‍👧‍👧 👍🏽 <- My use case is detecting first user perceived character in a String
r

Ryan

06/16/2020, 12:08 PM
can you elaborate some more
➕ 1
a

Attila Blenesi

06/16/2020, 12:28 PM
String[0] in the cases I posted return the first section of the unicode character that the emote is composed of :
val text = "👩‍👩‍👧‍👧 user perceived characters 👍🏽"
print(text[0])

?
👩‍👩‍👧‍👧 =
\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC66
Android Studio does not support Zero Width Joiner characters so it look like this in the IDE:
r

Ryan

06/16/2020, 12:28 PM
unicode takes up more than one position in a string
➕ 1
https://stackoverflow.com/questions/24531751/how-can-i-split-a-string-containing-emoji-into-an-array
🕸️ 1
a

Attila Blenesi

06/16/2020, 12:35 PM
Yeah, I'm asking because I did not see any clear way to achieve this in Kotlin / Java / Android (the question posted is web specific.)
I happy to create a Stack Overflow question myself.
Seems like https://developer.android.com/reference/android/icu/text/BreakIterator might be what I need
This was
Added in API level 24
So would still need something backwards compatible
g

Gonçalo Palaio

06/16/2020, 6:26 PM
Nothing is simple when dealing with emoji and I’m probably missing the point but couldn’t you loop through the codepoints and find the zero width joiners?
a

Attila Blenesi

06/20/2020, 11:56 AM
You are right to some extent, there are some cases where zero width joiners are not present.
View count: 1