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

    Brian Dilley

    04/06/2021, 12:26 AM
    destination.filterKeys { key ->
        key in (list1 + list2 + list3)
    }
    v
    2 replies · 2 participants
  • b

    Brian Dilley

    04/06/2021, 12:27 AM
    hopefully that gets optimized so that it’s not doing that concat of lists every time
    a
    e
    2 replies · 3 participants
  • l

    Lilly

    04/06/2021, 12:33 AM
    It creates a new list every time right? I forgot about
    when
    :
    destination.filterKeys { key ->
        when (key) {
          in list1, list2, list3 -> true
          else -> false
        }
    }
    I'm fine with this, if no one else has a more convenient solution
    e
    v
    12 replies · 3 participants
  • s

    Slackbot

    04/06/2021, 4:37 AM
    This message was deleted.
    🇳🇴 2
    👎 4
    :not-kotlin: 1
    b
    t
    +1
    15 replies · 4 participants
  • s

    Saket Poddar

    04/06/2021, 3:29 PM
    Folks, can anyone tell me when viewModel is killed by process death what happens to
    lateinit var sampleString: String
    , will it be initialised with null or will remain uninitialised ?
    j
    z
    13 replies · 3 participants
  • s

    Susheel

    04/06/2021, 4:41 PM
    is Kotlin copy function synchronous (blocking)? I think it is but wanted to make sure.
    z
    5 replies · 2 participants
  • l

    Lilly

    04/07/2021, 2:01 AM
    I was playing around with
    interfaces
    and
    sealed classes
    and noticed that both can be used to achieve the same. For example:
    Profile.kt
    interface Profile
    
    AProfile.kt
    class AProfile : Profile { }
    
    BProfile.kt
    class BProfile : Profile { }
    With sealed class:
    Profile.kt
    sealed class Profile
    
    class AProfile : Profile()
    class BProfile : Profile()
    Now I'm wondering what are the reasons to prefer one over the other?
    🇳🇴 1
    e
    z
    10 replies · 3 participants
  • r

    rkeazor

    04/07/2021, 3:47 PM
    hey how do you opt into the new IR backend , for a multi module android project
    s
    a
    6 replies · 3 participants
  • v

    Vyshas

    04/08/2021, 7:17 AM
    Has anyone tried or used mobile security solutions for your apps ? I have shortlisted two of them that spiked my interest and they are guardsquare (guardsquare.com) and zimperium(zimperium.com). It would be helpful if someone could let me know if you had experience with these products as I'd like to improve my app security
    :stackoverflow: 2
    :not-kotlin: 4
    u
    j
    39 replies · 3 participants
  • j

    Javier

    04/08/2021, 12:31 PM
    I have a this property in a CustomView which is a published module
    var onTextChanged: ((text: String) -> Unit)? = null
    but when I do
    onTextChanged = { ... }
    , there is an inference issue where it detects the
    String
    as
    Any
    . How can I solve this problem?
    3 replies · 1 participant
  • g

    Geert

    04/08/2021, 2:10 PM
    Anyone familiair with https://developer.android.com/studio/build/shrink-code#native-crash-support I cant find the generated native-debug-symbols.zip file
    :not-kotlin: 3
    l
    1 reply · 2 participants
  • t

    Tiago Nunes

    04/08/2021, 4:35 PM
    Hi everyone, is there a way to get the the previously emmited value of a flow in the onEach function, or something like this?
    private val refreshJob = filterFlow
        .onEach { prev, new ->
            if(prev.x != new.x) {
                updateX()
            }
        }
        .launchIn(viewModelScope)
    I know I can separate the filterFlow in multiple flows, which is probably the better way of solving my use case, but I'm still curious
    z
    i
    +1
    7 replies · 4 participants
  • b

    Bradleycorn

    04/08/2021, 9:48 PM
    I'm running into a problem with the
    Navigation Component
    and a ViewModel scoped to a nav graph ... I'm removing a few places in my app where I was using
    onActivityCreated
    in some fragments, since that callback is deprecated. I've been able to move most everything related to view work into
    onViewCreated
    , but I have a problem there because I need to do a few things with a nav graph scoped ViewModel. The problem is that when the containing activity is recreated (due to a configuration change, or process death, etc) the
    onViewCreated
    gets called before the containing Activity's
    onCreate
    is finished (in fact, it gets called as soon as the activity's
    onCreate
    is called). As a result, the Nav Graph has not been setup yet, and so it can't properly create the ViewModel that is scoped to the graph, and the app crashes. What's the path forward here? Per the deprecation notice in the docs for
    onActivityCreated
    , in the fragment's
    onAttach
    we should register a LifecycleObserver on the activity, observe for
    on_create
    and do work there. But that dooesn't work for me either. One of the things I need to do with the ViewModel is observe a LiveData, and the
    viewLifecycleOwner
    is not yet available (it's not available until the Fragment's
    onCreate
    ) ... the problem I'm running into is that after a configuration change, the Activity's onCreate and the Frgment's onViewCreated are executed in parallel, as illustrated by @ppvi in this article: https://medium.com/androiddevelopers/the-android-lifecycle-cheat-sheet-part-iii-fragments-afc87d4f37fd#4e7a . As outlined there, the benefit of onActivityCreated is that it is guaranteed to be called AFTER the Activity's
    onCreate
    is finished.
    i
    c
    10 replies · 3 participants
  • m

    Mohan Babu Malairaj

    04/09/2021, 3:33 AM
    Dear Community I have a use case where i have to add couple of values to data store, we are already in the process of moving away from shared preferences, inside a library but i already have a data store created for main app module as there was a need earlier. 1. Move the entire data store manager class to library so that both main and app module can access it - If i add a new module then this becomes a pain point so this should not be a good choice - please correct me if i am wrong. 2. create a new data store in a different name for the library module and use it Please let me know your feedback. Thank you!
    :not-kotlin: 3
    1 reply · 1 participant
  • h

    Hazem Muhammad

    04/09/2021, 7:58 AM
    Hey Guys, I'm a little bit confused so I need your advice. I used to be an android developer for some time and I can say I've done a good job in my android journy. but now with cross-platform rising up, I've a tough time choosing which platform should I use. I'm confused about kotlin multiplatfrom or flutter. as each of them has its downsides and I can't choose one of them (I'm talking about KMP which includes (desktop also not KMM)
    a
    c
    +1
    10 replies · 4 participants
  • u

    ubu

    04/09/2021, 12:25 PM
    class SomeWidget : ConstraintLayout {
    
        constructor(
            context: Context
        ) : this(context, null) {
    
        }
    
        constructor(
            context: Context,
            attrs: AttributeSet?
        ) : this(context, attrs, 0) {
    
        }
    
        constructor(
            context: Context,
            attrs: AttributeSet?,
            defStyleAttr: Int
        ) : super(context, attrs, defStyleAttr) {
            inflate()
        }
    
        fun addSubviews() {
            val views = mutableListOf<View>()
            repeat(2) { count ->
                views.add(
                    TextView(context).apply {
                        text = "Test $count"
                        setBackgroundResource(R.drawable.rectangle_debug)
                    }
                )
            }
            views.forEach {
                addView(it)
            }
    
            flow.apply {
                //setWrapMode(Flow.WRAP_CHAIN)
            }
    
            flow.referencedIds = views.map { it.id }.toIntArray()
    
            post { requestLayout() }
        }
    
        private fun inflate() {
            LayoutInflater.from(context).inflate(R.layout.widget_featured_relation, this)
        }
    }
    <?xml version="1.0" encoding="utf-8"?>
    <merge xmlns:android="<http://schemas.android.com/apk/res/android>"
        xmlns:app="<http://schemas.android.com/apk/res-auto>">
    
        <androidx.constraintlayout.helper.widget.Flow
            android:id="@+id/flow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="16dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
    </merge>
    I am totally missing something. Could someone explain to me why this custom view is rendered this way:
    :not-kotlin: 2
    :thread-please: 3
    e
    2 replies · 2 participants
  • u

    Umar Ata

    04/09/2021, 6:35 PM
    Hi there Why I need to make the binding instance to null in onDestroyView
    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }
    Does the garbage collection type thing not works with viewbindig ? Or I am on wrong track Please advise
    :not-kotlin: 3
    👍 2
    c
    m
    +3
    5 replies · 6 participants
  • f

    Florian

    04/10/2021, 4:04 PM
    Is this the correct way to turn an enum (in a utility class) to a localized readable string?
    fun getHumanReadableName(context: Context) =
                context.getString(
                    when (this) {
                        POMODORO -> R.string.pomodoro
                        SHORT_BREAK -> R.string.short_break
                        LONG_BREAK -> R.string.long_break
                    }
                )
    j
    e
    +1
    12 replies · 4 participants
  • m

    Mjahangiry75

    04/11/2021, 8:57 AM
    Hi, I created a jks sign for my releases app, now the jks sign file has been deleted and I have all the sign information I create a new jks sign file with exactly the same information but google play block the new one, while the old one was accepted by google
    :not-kotlin: 5
    e
    2 replies · 2 participants
  • m

    Muhammed Dag

    04/11/2021, 12:47 PM
    hello
    👋 8
    🙂 3
    :not-kotlin: 9
    t
    2 replies · 2 participants
  • s

    Slackbot

    04/12/2021, 8:07 AM
    This message was deleted.
    :not-kotlin: 1
    a
    1 reply · 2 participants
  • a

    André Thiele

    04/12/2021, 8:13 AM
    I have currently problems using the Kotlin Stdlib in my Android Projects. Autocomplete is not showing results from the stdlib. I tried everything from Invalidate Caches Restart, Re-installing Android Studio, downgrading to Canary 13. Opening the very same project in IntelliJ IDEA it works correctly but since this is a compose project its not an option. Any other ideas why this could be happening?
    👀 1
    v
    4 replies · 2 participants
  • a

    Android75

    04/14/2021, 3:03 AM
    hi i'm new with flow and StateFlow. I have this architecture with LiveData:
    open class BaseViewModel<State : Any, Event : Any> : ViewModel() {
    
    
    
         private val stateLiveData: MutableLiveData<State> = MutableLiveData()
    and now with StateFlow:
    open class BaseFlowViewModel<State : Any, Event : Any> : ViewModel() {
    
    
    
    
    
          private val _uiState = MutableStateFlow<State>()
    
        val uiState: StateFlow<State> = _uiState
    MutableStateFlow<State>() wants a parameter... what can i put as paramter?
    c
    k
    +3
    30 replies · 6 participants
  • n

    Nikhil

    04/14/2021, 4:45 AM
    what is the difference between extending 
    ListAdapter
     and 
    RecyclerView.Adapter
    ?
    k
    i
    +1
    5 replies · 4 participants
  • s

    Slackbot

    04/14/2021, 8:03 AM
    This message was deleted.
    e
    a
    3 replies · 3 participants
  • m

    missguru

    04/14/2021, 10:53 AM
    Hey everyone, We at Coder Bee host Hack Evenings every Wednesdays at 1830. It’s a safe and inclusive community to discuss your problems, projects and ideas with like-minded folks. We have mentors who can help and provide essential support! 👭👬🧑‍🤝‍🧑 Come by and hack away ... 👩‍💻  https://meetu.ps/e/JX2Ls/5Jn2C/d
    :not-kotlin: 4
    1 reply · 1 participant
  • a

    alex.tavella

    04/14/2021, 9:25 PM
    Does anybody know when exactly UnknownHostException is thrown when making a connection in Android? To me it seems that it could either be a DNS error, the server is down, or the client has no connection, but I’m not sure.
    :not-kotlin: 6
    p
    2 replies · 2 participants
  • e

    elye

    04/15/2021, 12:52 PM
    Hi, anyone knows, can Android CookieManager sync across two different Android Processes? I can't seems to get it work properly. More about it here. https://stackoverflow.com/questions/67108553/android-cookiemanager-setcookie-doesnt-sync-across-different-process
    :not-kotlin: 2
    i
    4 replies · 2 participants
  • i

    Ifvwm

    04/16/2021, 5:51 AM
    class DownloadStructure(val name: String, val link: String, val size: Int) { fun fmap (f: (String) -> String): DownloadStructure = DownloadStructure(name, f(link), size) } // why this would cause class Redeclaration error?
    a
    1 reply · 2 participants
  • j

    jd07

    04/16/2021, 6:41 AM
    I want protect application from reverse engineering. I apply the stackoverflow ans change in build.gradle. it's just change variables name only. It's any other way stop reverse engineering .
    :not-kotlin: 7
    p
    a
    +1
    4 replies · 4 participants
Powered by Linen
Title
j

jd07

04/16/2021, 6:41 AM
I want protect application from reverse engineering. I apply the stackoverflow ans change in build.gradle. it's just change variables name only. It's any other way stop reverse engineering .
:not-kotlin: 7
p

Pavel Sidyakin

04/16/2021, 7:07 AM
Dexprotector, but it's expensive
a

ArsalImam

04/16/2021, 6:03 PM
I generally move string literals to ndk, it makes dynamic analysis a bit more complex
e

enighma

04/16/2021, 6:49 PM
There's not way to stop reverse engineering, so I think it's important to state that so we don't fool ourselves. All you can do is delay and make it harder. Step 1 Is code obfuscation. Step 2 Move important code to native. It's harder to reverse engineer an SO library, but if someone wants to they will. Step 3 Move important logic to the backend. 2 & 3 will impact the product experience and costs more in terms of impl time. There might be off the shelf solutions, but all they do is most likely something of the above.
j

jd07

04/20/2021, 11:37 AM
Ok
View count: 9