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

    yunus emre Çiftçi

    09/03/2022, 5:30 PM
    Android mobil
  • s

    Subodh Nijsure

    09/03/2022, 10:34 PM
    I have textfield that I am setting text string and observing strange issue If the string is "🙏" which is codepoints 128591 1f64f I see the first image, But if the string is "🙏🙏" which is basically 2 code points with values 128591 128591, I see the second image Is there something special I need to do in order for the first emoji to get rendered correctly in a textView? The emoji in question is - https://www.unicodepedia.com/unicode/emoticons/1f64f/person-with-folded-hands/
    s
    a
    • 3
    • 8
  • n

    NelsonC

    09/04/2022, 12:22 AM
    Any way to make an object such as a sound start on background without a button on Android studio? I can make it as a button to start but haven't found resources to make it start automatically as the activity starts . Would really appreciate the help. Using kotlin language that is
    e
    • 2
    • 1
  • p

    paulex

    09/04/2022, 8:20 PM
    Is it a good idea to pass an intent to a viewModel ?
    a
    • 2
    • 2
  • a

    Aaron Waller

    09/04/2022, 10:05 PM
    Are there any tutorials on how to sideload Baseline Profiles besides the official docs? They explain it pretty poorly
  • b

    Ben Edwards

    09/05/2022, 12:19 PM
    Trying to get my head around Views & Widgets. Am I correct in thinking widgets are a type of 'bottom level' Views (i.e. Buttons, TextView...) that do not contains Views.
    c
    • 2
    • 1
  • b

    Ben Edwards

    09/05/2022, 6:33 PM
    OK sorry me again, with some not great code from a course (they are slowly sorting out code to show problems and how to make it better).
    override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
        Log.d(TAG, "getView called pos $position")
    
        // if convertView is null inflate it otherwise use it
        val view =
            if (convertView == null) {
                Log.d(TAG,"getView called with null convertView")
                inflater.inflate(resource, parent, false)
            } else {
                Log.d(TAG,"getView privided a convertView")
                convertView
            }
    
        val tvName: TextView = view.findViewById(R.id.tvName)
        val tvArtist: TextView = view.findViewById(R.id.tvArtist)
        val tvSummary: TextView = view.findViewById(R.id.tvSummary)
    
        val currentApp = applications[position] // position from constructor
    
        tvName.text = currentApp.name
        tvArtist.text = currentApp.artist
        tvSummary.text = currentApp.summary
    
        return view
    }
    Its the 'val view =' bit I have a question about. I get what it is doing, i.e. only running the inflator if needed. What I don't get is why when the method is run again convertView is set. i.e. when is convertView set to view?
    e
    • 2
    • 2
  • g

    gts13

    09/05/2022, 7:39 PM
    I have a very tricky question that nobody was able to answer it so far. My app needs to create and save a JSON file in the external storage. When I uninstall the app and install it again, I want to click a button that opens a file picker and pick the JSON file I have created before. Is that possible?
    c
    r
    • 3
    • 3
  • a

    Ankit Patel

    09/05/2022, 9:22 PM
    You can save your file in external storage. If you store in external storage than user can see or open file using file manager.
  • p

    Parth Gupta

    09/06/2022, 6:18 AM
    Hi all check this article on optimising recycler item inflation by using prefetch view pool https://tech.winzogames.com/optimizing-recyclerview-pre-inflated-viewpool-eaf5a6dd242a
  • a

    Ashish Gautam

    09/06/2022, 9:53 AM
    Hello all ! I'm working on android project where I'm doing background task or say tracking location, putting application on background. Now let say my application get destroyed after 3-4 hours due to any reason (most probably OS) I'm tracking my device outages(Active , inactive , app is not reachable) on my backend, so is there any way to trigger some kind of dialogue or wake my application up after get destroyed automatically (so I get location updates properly). hopefully I described my case. I will appreciate your approaches.
    m
    d
    • 3
    • 2
  • m

    Maksims Kims

    09/06/2022, 11:36 AM
    Hey, everyone! Just a quick question, does anyone has experience with integrating Ionic Portals into an Android app? I am interested in how does it affect the code quality and development process. Any input would be really appreciated!
  • s

    Shashi K

    09/06/2022, 12:23 PM
    Hey, n our app we have SIP module (pjsua2), which has the JNI libs libc++_shared, libpjsua2 • When we try to integrate Zoom SDK(mobilertc and commonlib) we are getting compile exception saying _2 files found with path ‘lib/arm64-v8a/libc++_shared.so’ from inputs:_ _- pjsua2/build/intermediates/library_jni/debug/jni/arm64-v8a/libc++_shared.so_ _- /mobilertc/build/.transforms/445b8adf65ed1845334c5eaf41712982/transformed/jetified-mobilertc/jni/arm64-v8a/libc++_shared.so_ I tried to use packageOptions pickfirst like below to resolve this
    android{
      packagingOptions {
          pickFirst 'lib/x86/libc++_shared.so'
          pickFirst 'lib/x86_64/libc++_shared.so'
          pickFirst 'lib/armeabi-v7a/libc++_shared.so'
          pickFirst 'lib/arm64-v8a/libc++_shared.so'
      }
    }
    The compinlation issue is resolved but when I invoke Zoom API not able find _/libc++_shared.so_
  • s

    Shashi K

    09/06/2022, 12:24 PM
    help is appreciated
  • a

    Aaron Waller

    09/06/2022, 7:13 PM
    Hey guys, is there a similar slack/discord channel like this one but for general android questions? I really love this slack but as soon as I have a question about something that has nothing to do with Kotlin for example Baseline Profiles, ART, gradle etc. I don’t know where to post my questions. My questions on StackOverFlow mostly remain unanswered.
    c
    b
    • 3
    • 2
  • m

    martin suchodol

    09/07/2022, 8:35 AM
    Hi, can anyone give me some advice? As part of my learning I decided to create a simple application working with the openWeather API. But I ran into a problem regarding the request.
    val url = "<https://api.openweathermap.org/data/2.5/forecast/daily?q=hamburg,de&appid=33aa634c216259f797f35e862f07****>"
    val resultJson = URL(url).readText()
    Log.d("Weather Report", resultJson)
    val jsonObj = JSONObject(resultJson)
    val main = jsonObj.getJSONObject("main")
    Attempting to execute then brings up the following: https://pastebin.com/84EDhwyU The debug basically did not detect any faults. Anyway, the bug refers this line:
    val resultJson = URL(url).readText()
    Edit: I will add that when I played with it yesterday I somehow mysteriously managed to get the resulting JSON, but only once and without any code modification. It's as if each time the resulting JSON was loaded incorrectly
    c
    • 2
    • 1
  • c

    Ciaran Sloan

    09/07/2022, 10:01 AM
    you can add the directory as a standard directory, create the
    src
    directory and add your gradle file. Then in the
    settings.gradle
    file add the new module as
    include ':ui:my-module'
  • j

    Juliane Lehmann

    09/07/2022, 3:34 PM
    Which kind of Button are you importing?
    b
    • 2
    • 2
  • y

    yousef shaaban

    09/08/2022, 8:42 AM
    Hi all, any one try generate coverage inline documentation using dokka
  • b

    Bilel El Oud

    09/08/2022, 9:13 AM
    Hi all, I would like to start learning Kotlin programming language, i want to start from scratch. Please send me links and documentations to get started. Thanks.
    k
    • 2
    • 1
  • s

    Siergej Sobolewski

    09/08/2022, 9:18 AM
    Hello friends, I just started learning Kotlin. I would be grateful for good advice or a joint project.
  • a

    arekolek

    09/08/2022, 10:49 AM
    do you run
    detekt
    on debug or release build type and why?
    z
    z
    • 3
    • 4
  • j

    Jaime

    09/08/2022, 10:47 PM
    Hello everyone, I have a problem doing a startActivity to an Activity that is in another module of the application. I have this error. Maybe it has happened to someone else and they can help me
    android.content.ActivityNotFoundException: Unable to find explicit activity class {package/packgae.OtherActivityInFeatureModule}; have you declared this activity in your AndroidManifest.xml?
    I was seeing that it is added in the manifest-merge but I still have the error I am creating the intent like this
    fun intentToClear(intentActivity: IntentActivity, bundle: Bundle? = null): Intent {
        val intent = Intent(Intent.ACTION_VIEW).setClassName(PACKAGE_NAME, intentActivity.className)
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
        bundle?.let {
            intent.putExtras(it)
        }
        return intent
    }
    e
    • 2
    • 3
  • a

    Ashish Gautam

    09/09/2022, 11:52 AM
    Can we do constructor injection in serivice class
    class MyFirebaseMessagingService @Inject constructor(private val repository : Repository) :
        FirebaseMessagingService() {
    p
    • 2
    • 2
  • m

    martin suchodol

    09/11/2022, 8:50 AM
    Hi, I need help with this error:
    Unable to create converter for retrofit2.Call<com.marsuch.weatherapp.network.WeatherInfo>
    for method WeatherApiService.getWeatherData
    I have found a number of different solutions on the internet however none of them work for me. I use Moshi with retrofit. My WeatherInfo.kt
    data class WeatherInfo (
        val city : City,
        val cod : Int,
        val message : String,
        val cnt : Int,
        //val list : List<Weather>,
        )
    
    data class City (
        val id : Int,
        val name : String,
        //val coord : Coord,
        val country : String,
        val population : Int,
        val timezone: String?
        )
    WeatherApiServices.kt
    import com.squareup.moshi.Moshi
    import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
    import retrofit2.Call
    import retrofit2.Retrofit
    import retrofit2.converter.moshi.MoshiConverterFactory
    import retrofit2.http.GET
    import retrofit2.http.Query
    
    private const val BASE_URL = "<http://api.openweathermap.org/data/2.5/>"
    private var lon: String = ""
    private var lat: String = ""
    private var appId: String = ""
    
    private val moshi = Moshi.Builder()
        .add(KotlinJsonAdapterFactory())
        .build()
    
    private val retrofit = Retrofit.Builder()
        .addConverterFactory(MoshiConverterFactory.create(moshi))
        .baseUrl(BASE_URL)
        .build()
    
    interface WeatherApiService {
        @GET("forecast/daily")
        suspend fun getWeatherData(
            @Query("lat") lat : String,
            @Query("lon") lon : String,
            @Query("appid") apiKey : String
        ): Call<WeatherInfo>
    }
    
    object WeatherApi{
        val retrofitService : WeatherApiService by lazy {
            retrofit.create(WeatherApiService::class.java)
        }
    }
    The resulting data are displayed as follows:
    private val _status = MutableLiveData<String>()    
    
    fun getData() {
            viewModelScope.launch {
                try {
                    val listResult = WeatherApi.retrofitService.getWeatherData(lat, lon, api)
                    //_status.value = "Success ${listResult} wether data retrieved"
                    Log.d("Response weather:", listResult.toString())
                }
                catch (e: Exception) {
                    _status.value = "Failure: ${e.message}"
                    Log.e("Failure", e.message.toString())
                }
            }
        }
    I'm still learning, so I apologize if the solution to the error is trivial.
    c
    • 2
    • 4
  • e

    Eric Womer

    09/11/2022, 9:27 PM
    is there a sight to look up jetpack compose api
    z
    g
    • 3
    • 3
  • e

    Eric Womer

    09/11/2022, 9:27 PM
    reference?
  • b

    Ben Edwards

    09/12/2022, 12:10 PM
    I can test my app on a mobile phone but cant get emulator working. Ive tried emulators using SDK 17, 26 & 29 but it always hands when it get to
    var data = URL(params[0]).readText()
    it hangs(I used a debugger and when it runs the code it just never comes back, the code is in AsyncTask.doInBackground (I know it depreciated, I am doing tutorials). Any advice? The URL is
    <https://www.flickr.com/services/feeds/photos_public.gne?tags=android,%20oreo&tagmode=any&format=json&nojsoncallback=1>
    This works fine if I just do it in InteliJ. I know URL is Java but the readText extension is. if it's not enough Kotlinly can someone point me to a good alternative place to ask question?
  • r

    rrg

    09/12/2022, 7:03 PM
    For an Android dev like me who has been doing traditional Android/Java programming and is new to Kotlin looking into implementing a KMM lib common to both our Android and iOS apps, what would be the best place to start learning Kotlin (and eventually KMM)? Would that be the official Android Kotlin docs or is there a good tutorial series somewhere like Youtube that provides a good crash course on Kotlin (and KMM too)? TIA!
    m
    j
    • 3
    • 2
  • a

    Ashish Gautam

    09/13/2022, 8:04 AM
    Hello there ! I want to go into Unit Testing TDD, which course or any pathway do you recommend
Powered by Linen
Title
a

Ashish Gautam

09/13/2022, 8:04 AM
Hello there ! I want to go into Unit Testing TDD, which course or any pathway do you recommend
View count: 13