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

    Souhail Marghabi

    05/29/2020, 5:45 AM
    Hello Everyone, I had to recently dive in a project that uses GStreamer to video stream on the app h264 encoded videos from a remote camera device. This doesnt seem to work on Android 5 and above even after updating the library.(the surfaceview is black). Anyone with experience with, or knows of good android libraries to read and display video stream(H264 encoded) in an app?
    :stackoverflow: 1
    o
    • 2
    • 19
  • i

    iex

    05/29/2020, 8:04 AM
    Hi! Any recommendations re: nesting a vertical (variable length, short) text items list inside recycler view cells? I usually put everything in a flat list, using different cell types, but this can be visually not optimal if you want to show something that spans multiple "child" cells. Or just filling programmatically nested linear layouts? But this doesn't seem to play along well with recycling, since the parent cells have to remove and re-add the rows all the time. Or nested recycler view (this may be overkill, and does a nested recycler view even perform well)?
    e
    • 2
    • 3
  • i

    Ifvwm

    05/29/2020, 8:34 AM
    how I can update a TextView in other file, not MainActivity.kt?
    o
    i
    • 3
    • 4
  • t

    T

    05/29/2020, 12:01 PM
    I want to extract the array data from the json response and store the data in my custom data class.
    data class NewsData (
    
        val author: String, val title: String,
        val url: String, val publishedAt: String
    )
    class NewsViewModel : ViewModel() {
    
        // The internal MutableLiveData String that stores the most recent response
        private val _response = MutableLiveData<String>()
    
        // The external immutable LiveData for the response String
        val response: LiveData<String>
            get() = _response
    
        /**
         * Call getNewsData() on init so we can display status immediately.
         */
        init {
            getNewsData()
        }
    
        /**
         * Sets the value of the status LiveData to the News API status.
         */
        private fun getNewsData() {
    
            _response.value = NewsApi.retrofitService.getProperties().enqueue(
                object : Callback<ResponseBody> {
                    override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
                        _response.value = "Failure: " + t.message
                        //Log.i("response", t.message)
                    }
    
                    override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {
                        val root = JSONObject(response.body().toString())
                        val jsonArr = root.getJSONArray("articles")
                        val ob = jsonArr.getJSONObject(0)
                        val name = ob.getString("author")
                        _response.value = name
                    }
                }).toString()
        }
    }
    This is the format of the json response.
    o
    • 2
    • 19
  • a

    Adam

    05/29/2020, 1:38 PM
    https://bitbucket.org/adam_nadar/github-browser/commits/deb82620c48459816f05261fe9e92c20bd13173f Some reviews for this commit
    o
    • 2
    • 2
  • t

    T

    05/29/2020, 10:17 PM
    How do I retrieve the element "author", "tittle" etc from a json response like this. Am using retrofit and moshi.
    :google: 7
    :stackoverflow: 7
    h
    • 2
    • 2
  • a

    Azhar

    05/30/2020, 5:18 AM
    @android how can I get the storage path of usb drive.list files can display also
    :google: 3
    g
    • 2
    • 1
  • n

    Nikola Milovic

    05/31/2020, 8:23 AM
    Hey guys, how can I add a header to a recycle view, that is another recycle view? Something like stories on Instagram. Where if you're all the way up, you can see them as you scroll they disappear.
    👍 2
    :google: 5
    :stackoverflow: 2
    d
    z
    • 3
    • 15
  • r

    Remon Shehata

    05/31/2020, 10:12 AM
    for (item in statusList) {
                Log.d(TAG, item)
                filteredReport.filter { it.status == item }
            }
    a
    b
    s
    • 4
    • 3
  • m

    Mohamed Ibrahim

    05/31/2020, 7:33 PM
    Hello I’ve used this code to animate views while fragment replacement
    transaction.addSharedElement(buttonSignIn, buttonSignIn.transitionName)
            .addSharedElement(socialSigninButtonContainer, socialSigninButtonContainer.transitionName)
            .addSharedElement(signInInputsContainer, signInInputsContainer.transitionName)
            .addSharedElement(textViewCopyright, textViewCopyright.transitionName)
    
    val autoTransition = AutoTransition().also {
        it.interpolator = AccelerateInterpolator()
    }
    fragment.allowEnterTransitionOverlap = true
    fragment.allowReturnTransitionOverlap = true
    fragment.sharedElementEnterTransition = autoTransition
    the problem is I want to add a fading out/in animation with sync with the sliding one
    ❤️ 2
    :google: 3
    🤔 1
    s
    • 2
    • 2
  • v

    Vivekpanchal64

    06/01/2020, 8:41 PM
    Hey guys can anyone help me with networkboundresource helper class with corrutines ?? Anyone tried that ?
    :google: 4
    👍 2
    s
    d
    z
    • 4
    • 5
  • j

    Javier

    06/01/2020, 9:32 PM
    Is not possible to download the Kotlin 1.4 plugin with Android Studio 4.1 Canary 10?
    i
    l
    • 3
    • 6
  • n

    Nikolay Puliaev

    06/02/2020, 1:59 PM
    Hi, guys. Could you please suggest good way for file downloading using coroutines? At the moment I’m using retrofit with Streaming, but it stops after loading some large amount of files. I don’t know the reason but it just stops, without throwing any exception.
    h
    • 2
    • 1
  • j

    Joao Birk

    06/02/2020, 7:13 PM
    Hi there, question about navigation components and the use of: https://github.com/android/architecture-components-samples/blob/master/NavigationAdvancedSample/app/src/main/java/com/example/android/navigationadvancedsample/NavigationExtensions.kt I have a bottomNavigationView with 5 tabs (therefore 5 navigation graphs) and each tab has its own deep links. I'm having an issue with deep links where if I leave the app (put in on background) with the second tab selected, push an intent that deep links to the first tab, the app is open on the second tab and the linking doesn't happen. I have also added the following code:
    override fun onNewIntent(intent: Intent) {
        super.onNewIntent(intent)
    
        if (currentNavController?.value?.handleDeepLink(intent) == false) {
        ...
        }
    }
    I understand the problem, basically the
    currentNavController.value
    which has the
    navigation_graph_2.xml
    doesnt have such deep link set...how can I check if other graphs (tabs) support such deep link and then navigate to the desired tab?
    i
    • 2
    • 2
  • d

    Diego Marulanda

    06/03/2020, 1:45 AM
    Hi, could someone help me out by telling me, how I could create a declarative (without modifying xml) image slide in Jetpack Compose? I would appreciate it🙆‍♂️
    z
    • 2
    • 2
  • k

    Kevin

    06/03/2020, 5:53 AM
    Hi there, i would like to create a dot indicator to show the user on which layout they are currently right now. i want to make that the dot indicator changed position when the main button that trigger the layout change is clicked. i've seen multiple reference and library about dot indicator, and almost all of them was automatic or changed when user scrolls the layout. so i would like to know if is there a way to do this, but by clicking button as a trigger?(and button as in additional button, not by clicking the dot indicator) any help would be appreciated, thank you.
    o
    • 2
    • 3
  • e

    Elias

    06/03/2020, 7:53 AM
    Hello, was hoping for some input in to an issue we're having. When using mediator live data, how does one prevent it from updating the dataset twice (or more) on init. EDIT: To clarify, after the viewModel is initialised, we are getting expected behaviouor. See example:
    private val _foo: MutableLiveData<List<Foo>> = MutableLiveData()
    private val _bar: MutableLiveData<List<Bar>> = MutableLiveData()
    
    val fooBar: LiveData<List<FooBar>> = MediatorLiveData<List<FooBar>>.apply { 
        addSouce(_foo) { this.value = makeFooBarList() }
        addSouce(_bar) { this.value = makeFooBarList() }
    }
    
    init {
        loadFoo()
        loadBar()
    }
    We have been struggling with the viewModel being updated twice or more, which sometimes messes with tests, and can make the views take longer than necessary to load. Any tips and tricks are appreciated!
    v
    • 2
    • 6
  • s

    sanket

    06/03/2020, 2:05 PM
    Hello guys, I have an app that is used by multiple customers. Each customer has a little bit of modification in the business logic and has their own logo and color theme. Each customer expects customized app for same business solution. It is unwise to deploy one app for each customer with different names in playstore. I want to deploy a single app which when the customer downloads and logs in, he sees his company logo and color theme and Business logic. Can any one help me out with this type of deployment on play store please.
    r
    o
    +2
    • 5
    • 8
  • t

    Tim

    06/03/2020, 7:13 PM
    does anyone here use instant run? i remember using it a while ago but it was kind of inconsistent and sometimes caused some unexpected bugs, and im curious if switching back to using it is worth it
    s
    m
    +2
    • 5
    • 4
  • g

    Galou Minisini

    06/04/2020, 4:33 PM
    Any library recommendations to protect your app with a passcode/fingerprint. We used to use PasscodeLock from wordpress. But it is now deprecated..
    a
    w
    • 3
    • 3
  • m

    Michael Pohl

    06/04/2020, 5:00 PM
    Does anyone have an idea what would be the best practice for dealing with constants on Android today? As in, do I put them in companion objects or just have them at top level, and if so, how to organize that properly? What about private and public? I personally like companion object consts, but I'm being told that add makes them more expensive since the object needs to be instantiated. What is considered "right" here?
    ➕ 1
    w
    c
    p
    • 4
    • 6
  • i

    Ivann Ruiz

    06/05/2020, 3:48 AM
    Hi all 👋 published a new Android article. This time I chose to write about how I like to use sub-modules in my Android libraries to implement CLEAN architecture. It's targeted towards a beginner-intermediate audience but I think anybody from the community could benefit from it. Feedback/thoughts are both appreciated and welcomed! https://medium.com/@ivann.r/optimizing-android-libraries-for-clean-architecture-with-sub-modules-a63f7f8ad6b5
    👎 1
    👍 1
    o
    • 2
    • 1
  • a

    androidexpertmanish

    06/05/2020, 9:27 AM
    Any idea how Truecaller is filtering finance related sms only? I have tried with some regex pattern like AM-BankName but every bank or online transaction doesn't have same pattern. UPI, Online Payment, Credit Card and NetBanking all have different pattern. Need help.
    p
    • 2
    • 2
  • g

    Gaurav K Tyagi 1

    06/05/2020, 11:29 AM
    Hi @all How can we share viewmodel between diffetent activities ?
    k
    i
    o
    • 4
    • 9
  • a

    Ananiya

    06/05/2020, 5:23 PM
    is there difference between them
    ilove_kt.kt
    👍 1
    h
    n
    • 3
    • 2
  • d

    Deepti M

    06/05/2020, 5:36 PM
    Hi There, I need to test my app on Android versions <API-19. When trying to build an emulator of the same, it says your app would not run unless you update Googgle Play Services. But couldn't find any option to do so. Can anybody help?
    h
    a
    • 3
    • 13
  • r

    Remon Shehata

    06/05/2020, 11:50 PM
    Hello there, this is sort of a noop question. but I have been stuck for a couple of hours now. I am using constraint layout and the view looks good on 5" or bigger screens. but when I test it on smaller screens, for example, 4" or smaller. the views at the bottom get off the bottom of the screen. even though the view is constrained to the bottom. would creating a new layout for smaller screen sizes be the best solution?
    r
    c
    • 3
    • 17
  • a

    Azhar

    06/06/2020, 8:26 AM
    How can I update the apk manually in Android codw
    g
    • 2
    • 1
  • a

    Apex

    06/06/2020, 12:46 PM
    I am facing this flickering/text resizing in toolbar while using navigation component. Anyone know how I can solve this ? https://del.dog/unerrycyhi.txt contains the code I am using and layout XML.
    2020_06_06_17_01_57.mp4
    r
    i
    • 3
    • 4
  • r

    Remon Shehata

    06/06/2020, 10:52 PM
    Hello guys, I have a tricky question 😄 I have a function that adds a `User`object to firebase. and of course, it's a callback function. now what I want to add is to add a list of `User`s. a simple for loop won't do the trick since the callback function runs on a background thread. I thought of creating a function the returns the next user from the list. then I can use recursion and on the callback
    onSuccess
    I can call the same function again and pass in the next user. I think this would work but I am not sure it's the optimal way to do this..any ideas?
    a
    • 2
    • 3
Powered by Linen
Title
r

Remon Shehata

06/06/2020, 10:52 PM
Hello guys, I have a tricky question 😄 I have a function that adds a `User`object to firebase. and of course, it's a callback function. now what I want to add is to add a list of `User`s. a simple for loop won't do the trick since the callback function runs on a background thread. I thought of creating a function the returns the next user from the list. then I can use recursion and on the callback
onSuccess
I can call the same function again and pass in the next user. I think this would work but I am not sure it's the optimal way to do this..any ideas?
a

Adam Powell

06/06/2020, 11:11 PM
Turn the add operation into a suspend function and then you can use a simple for loop 🙂
👍 1
r

Remon Shehata

06/06/2020, 11:30 PM
I have never used it before. now it's the time to learn about it I guess.
one last question. if the add operation itself has many callbacks because it adds different documents(4 docs with collection inside them). each one after the other. it's working but it takes time. any suggestion to improve it?
:google: 1
View count: 4