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
  • h

    hetang

    08/26/2019, 5:22 AM
    @Akbar have you read this? https://developer.android.com/topic/security/data
    a
    • 2
    • 15
  • a

    Akbar

    08/26/2019, 7:37 AM
    Hi guys do we have any standard naming conventions for android applications like ids,res names etc?
    :google: 3
    :stackoverflow: 2
    a
    • 2
    • 9
  • e

    Efe

    08/26/2019, 12:48 PM
    dependencies { def security_version = “1.0.0-alpha02” implementation “androidx.security😒ecurity-crypto:$security_version” } https://developer.android.com/jetpack/androidx/releases/security
    a
    • 2
    • 2
  • m

    Marc Knaup

    08/26/2019, 5:09 PM
    And the other way round, a
    LiveData
    as `Flow`:
    @UseExperimental(ExperimentalCoroutinesApi::class)
    fun <Value> LiveData<Value>.asFlow() = channelFlow<Value> {
    	val observer = Observer(this::offer)
    	observeForever(observer)
    	awaitClose { removeObserver(observer) }
    }
    d
    a
    l
    • 4
    • 10
  • c

    Cody Engel

    08/26/2019, 6:02 PM
    SQLDelight question… Has anyone been able to successfully run
    generateSqlDelightSchema
    with version
    1.1.4
    ? It’s referenced in the readme but the task cannot be found, others have reported the issue without much traction so wondering if I’m missing something? https://github.com/square/sqldelight/issues/1400
    j
    • 2
    • 2
  • n

    Ngenge Senior

    08/26/2019, 8:05 PM
    d
    t
    • 3
    • 7
  • k

    Kelvin Pere

    08/27/2019, 1:56 PM
    i have been trying to get the popup message from ussd in android. I found a way. Please i would like to know if there is a better way of doing this https://github.com/Pheonix73/Read_USSD_Popup_to_LogCat
    👎 1
    a
    • 2
    • 7
  • a

    adams2

    08/27/2019, 3:39 PM
    why is this not a compile error due to
    @Nullable
    on findViewById conflicting with
    T : View
    (it's not
    T : View?
    )
    Untitled
    r
    • 2
    • 2
  • k

    Kulwinder Singh

    08/28/2019, 11:34 AM
    Hi, i have created this custom view and inside it i'm loading image using picasso like below, this custom view contains many other view with ImageView that's why it is extending
    ConstraintLayout
    -:
    class CustomView(context: Context, attrs: AttributeSet) : ConstraintLayout(context, attrs) {
        init {
            var a: TypedArray? = null
    	    ......
    	    val backgroundImage = a.getResourceId(R.styleable.CustomView_backgroundImage, -0)// image will be from assets
            inflate(context, R.layout.custom_view, this)
            if (backgroundImage != -0) Picasso.get().load(backgroundImage).into(img_background)
                .....
        }
    }
    with this code app compiles and on device it loads image. but problem is that it don't show image preview on android studio and android studio unable to render layout. any solution to this ?
    w
    • 2
    • 9
  • f

    farzad

    08/28/2019, 12:29 PM
    Hey guys. I have a data class named
    UserModel
    . There exist cases in my code which I used
    copy
    to clone the user model. My question is that is there a way to find all UserModel.copy calls?
    m
    w
    +2
    • 5
    • 14
  • i

    Icaro Temponi

    08/28/2019, 7:54 PM
    Hi everyone, just a basic question that I'm still not 100% shure: In your opinion what's the best CoroutineScope lifetime for activities and fragments? Currently I'm cancelling(the children) of the scope when a fragment is stopped and when an activity is destroyed. I used to cancel the scope when both were destroyed, but then I had some problems of running background operations not being cancelled when navigation to another fragment (fragment on backstack is stopped, not destroyed).
    d
    l
    +3
    • 6
    • 29
  • i

    igor.wojda

    08/29/2019, 10:27 AM
    What is the current state of
    Kotlin
    +
    Jacoco
    ? Can I use
    Jacoco
    to get
    JUnit
    test coverage of Kotlin code? Does some one uses is on day to day basics? How mature is it currently with Kotlin?
    w
    i
    c
    • 4
    • 8
  • e

    escodro

    08/30/2019, 1:03 AM
    https://android-developers.googleblog.com/2019/08/google-releases-source-code-for-google.html
    🎉 3
    p
    • 2
    • 1
  • o

    orcchg

    08/30/2019, 6:51 AM
    how could i initialize val in a method provided that method is only called from constructor? For example, I'm writing custom View like that:
    class IconItemView : LinearLayout {
    
        private var hideIcon: Boolean = true
    
       constructor(context: Context): this(context, null)
    
        constructor(context: Context, attributes: AttributeSet?): this(context, attributes, 0)
    
        constructor(context: Context, attributes: AttributeSet?, defStyleAttr: Int): super(context, attributes, defStyleAttr) {
            init(context, attributes, defStyleAttr)
        }
    
       private fun init(context: Context, attributes: AttributeSet?, defStyleAttr: Int) {
            context.obtainStyledAttributes(attributes, R.styleable.IconItemView, defStyleAttr, R.style.IconItemView)
                .apply {
                    hideIcon = getBoolean(R.styleable.IconItemView_icon_item_hide_icon, true)
                    recycle()
                }
        }
    Property hideIcon is essentially final, since it's only assigned in constructor, though there are *init*ialization method inside. I dont want to pass the whole method body to one of constructors, but Kotlin neither allows to have that init() fuctions as a local function in ctor, nor to make hideIcon properly as val Is there any way to make the property final?
    a
    e
    • 3
    • 2
  • l

    Laura de la rosa

    08/30/2019, 3:16 PM
    How optimal is to pass a parcelable list of 1000 rows or more from one fragment to another through a bundle? knowing that I can't persist that list and using navigation jetpack
    m
    j
    +4
    • 7
    • 19
  • h

    henrikhorbovyi

    09/01/2019, 5:07 PM
    Hey folks. I'm trying to use
    Coroutines Flow
    with Room and I'm receiving the following error:
    g
    • 2
    • 28
  • h

    henrikhorbovyi

    09/01/2019, 5:09 PM
    this is the type that Room can't convert ☝️
    k
    • 2
    • 1
  • t

    tseisel

    09/01/2019, 6:04 PM
    Given a 100% Kotlin Android project, does moving all code from
    src/main/java
    to
    src/main/kotlin
    has any positive impact on build speed ? I'd expect to avoid at least a java compiler pass.
    d
    w
    • 3
    • 6
  • i

    Ive Vasiljevic

    09/01/2019, 7:48 PM
    Can someone recommend a good Android Library for Web Scraping using Kotlin? I've seen a couple of Java libs like Jsoup.
    m
    • 2
    • 4
  • l

    lawlorslaw

    09/02/2019, 3:16 AM
    i would like to perform an expensive operation on a background thread with the use of coroutines. I scanned some documentation and some medium posts and looks like i really need to take a deep dive to understand how to use it. Basically the expensive operation will return a Collection of objects that i will use to populate a RecyclerView.Adapter. Can anyone provide a code snippet or some sample code that can do something like that?
    d
    g
    • 3
    • 3
  • e

    Eugen Martynov

    09/02/2019, 5:52 AM
    How do you people deal with LiveData nullability? I used it for data binding but it never nulls
    m
    • 2
    • 6
  • h

    heehawgr

    09/02/2019, 8:58 AM
    May I ask a question? What’s the point of these extension methods in the source code of _Collections.kt? Occasionally find them while reading codes, a little bit confused😶
    g
    • 2
    • 4
  • i

    Igor Maineti

    09/02/2019, 4:48 PM
    How do you deal with deeplinking? Are you using firebase dynamic links?
    c
    o
    • 3
    • 2
  • b

    bohsen

    09/03/2019, 8:59 AM
    Would it be safe to expose a
    Flow
    from a custom view or could this cause leaks?
    g
    r
    • 3
    • 18
  • d

    Damian J

    09/03/2019, 3:59 PM
    Hi, I am creating tracking app, which draws walked path into the map. App should work also with turned-off screen. I would like to use MVVM pattern. To ensure tracking with turned-off screen I am using foreground service, which implements LocationListener interface. Does anyone have any suggestions or examples how I should communicate between Service and viewModel to get updates liveData in viewModel on each localization change?
    w
    • 2
    • 2
  • t

    tjohnn

    09/03/2019, 4:53 PM
    Android studio 3.5 cannot resolve mockito imports though it compiles. How can I resolve this? I have tried all possible options like invalidating cache, restart, delete .gradle amd .idea etc
    n
    r
    r
    • 4
    • 9
  • d

    Darrinps

    09/03/2019, 5:13 PM
    @tjohnn Can't say for sure, but you might try deleting the imports then having Android Studio add them back for you and see if that helps. It's worked for me in the past with similar issues.
    t
    w
    • 3
    • 2
  • r

    Ronak Android

    09/04/2019, 9:40 AM
    https://github.com/RonakAndroid/VanillaPlacePicker
    👏 1
    m
    • 2
    • 1
  • r

    rook

    09/04/2019, 2:28 PM
    Is it considered good practice to utilize coroutines from an Activity/Fragment?
    c
    g
    • 3
    • 3
  • a

    Akbar

    09/04/2019, 2:48 PM
    is there any ternary operator in kotlin ?
    🇳🇴 11
    l
    c
    +2
    • 5
    • 5
Powered by Linen
Title
a

Akbar

09/04/2019, 2:48 PM
is there any ternary operator in kotlin ?
🇳🇴 11
l

Luke

09/04/2019, 2:56 PM
if
is an expression. You can do
val a = if (condition) "something" else "something else"
. See https://kotlinlang.org/docs/reference/control-flow.html
👍 1
c

Casey Brooks

09/04/2019, 2:57 PM
if
statements are expressions in Kotlin (they return a result) and so can be used to do exactly the same thing as the ternary operator, but is less confusing.
a = b ? c : d
is the same as
a = if(b) c else d
d

DALDEI

09/04/2019, 3:34 PM
6 extra bytes though ... P:))
s

Sam

09/04/2019, 4:50 PM
The elvis operator
?:
works well as a shorthand ternary dealing with nulls.
a = nullableValue ?: nonnullDefaultValue
a

Akbar

09/05/2019, 6:45 AM
thanks
View count: 5