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
stackoverflow
  • u

    user

    07/06/2022, 6:31 AM
    How to get the size of the file stored in firebase storage and its link in firebase storage? here is my code to get the file size but I am unable to get it.:- ImageURL is stored in realtime database Picasso.get().load(ImageURL).placeholder(R.drawable.ic_baseline_image_200) .into(selected_title_image) val storageReference = FirebaseStorage.getInstance().getReferenceFromUrl(ImageURL) ImageSize = storageReference.getBytes() ImageSize /= 1024 Toast.makeText(baseContext, ImageSize.toString(), Toast.LENGTH_SHORT).show() I use the reference of...
  • u

    user

    07/06/2022, 6:51 AM
    Export Room Database File and Send it to server using retrofit kotlin I want to export my database file and tehn send it to server using retrofit. Challenges: Cannot find the request body type for db file in retrofit to send.
  • u

    user

    07/06/2022, 6:51 AM
    onSlide is not called in Android Oreo when BottoSheet is initialized I'm having some issues on Devices with Android Oreo in my app i have a RecyclerView and a BottomSheet, when the BottomSheet is in STATE_EXPANDED or it's sliding i'm setting the RecyclerView bottom margins to fit the RecyclerView in remaining space. In other Android versions > Oreo there are no problems onSlide is called and the bottom margin is set. BottomSheetCallback bottomSheetTasti.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { @Override public void...
  • u

    user

    07/06/2022, 7:31 AM
    How I can Remove the margin between two item in ViewPager2 XML I'm trying to remove the margin between viewPager2 items when I scroll the page. >

    https://i.stack.imgur.com/qkmxt.jpg▾

    https://i.stack.imgur.com/zGsop.jpg▾

    I' trying to make simple application like tiktok but this an issue I'm facing while scrolling my videos.
  • u

    user

    07/06/2022, 7:31 AM
    android save data from background service i have a background service which is working in background and looking for new SMS and creating notification and showing SMS public class SmsBoradcast extends BroadcastReceiver { private static final String SMS = "android.provider.Telephony.SMS_RECEIVED"; @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals(SMS)){ Bundle bundle = intent.getExtras(); if (bundle != null) { Object[] pdus =...
  • u

    user

    07/06/2022, 7:31 AM
    ¿como comparar Doubles dentro de un MutableList en Kotlin? Tengo esto pero al ejecutarlo solo me compara el primer numero y se olvida de los decimales. dataList.sortWith(compareBy { notas -> getMiNota(notas.notas!!).toDouble() })
  • u

    user

    07/06/2022, 7:31 AM
    Issues with dummy data Date I have my dummy data for testing with a type of Date (java.util) but no matter what i put i always have a missmatch val dummyData = arrayListOf( Data("JUst a string", 2018-12-14, 100.0, 1.0), ) Missmatch: 2018-12-14 What should I put then?
  • u

    user

    07/06/2022, 7:51 AM
    How to display Image taken using Camerax API (Android) How to display the Image taken using CameraX in Android. My case : I have two fragments. In one of the fragments I have implemented the CameraX functionality to take the photo and save it locally. And now I want to pass this image to an another fragment and display it there in an ImageView. What should be the best approach for that ( and if you could provide a working code that would be helpful ) Approaches that I think of to solve this: 1st approach : Send the Uri Id that is extracted from...
  • u

    user

    07/06/2022, 7:51 AM
    Preview in android kotlin When I enter the program, a black screen is displayed for a few seconds and then it enters the program With the search I made, I used the following code and the black screen is not displayed, but when I try to enter the program, the whole phone freezes for a few seconds and then enters the program. I could not find a solution to this problem true
  • u

    user

    07/06/2022, 8:51 AM
    LiveData observer is not being called when changing value My observer is not being called when I change LiveData value. I have a ViewModel, a custom View and a Fragment. In ViewModel I set the LiveData, in the custom View is where I change the value of this LiveData and in Fragment is where I observe the LiveData. Using breakpoints, I see that my custom View is working fine and changing the LiveData value correctly but in Fragment, the observer only is called when the Fragment is created. ViewModel: class MyViewModel : ViewModel { private val...
  • u

    user

    07/06/2022, 8:51 AM
    is there a way to pass value from data class to another class in Kotlin? Sorry, I'm new to Java/Kotlin mobile apps... Below code snippet from RegisterFragment.kt which is the main class:- override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) val username = binding.text PackageSdk.getInstance().hasDuplicateUserKey(username, object : PackageResponseCallback { override fun onSuccess(result: ResultResponse) { Log.i(TAG, "Result code : " +...
  • u

    user

    07/06/2022, 8:51 AM
    Kotlin equivalent to Swift Literal Expression In Swift I use the following code to log a message and I receive all the relevant data I need: class func log(type: LogType, message: String, fileName: String = #file, line: Int = #line, column: Int = #column, function: String = #function) How can I do something similar in Android Java or Kotlin (preferable)? Thanks in advanced
  • u

    user

    07/06/2022, 9:11 AM
    function not working inside onRequestPermissionsResult why override fun onRequestPermissionsResult( requestCode: Int, permissions: Array, grantResults: IntArray ) { // super.onRequestPermissionsResult(requestCode, permissions, grantResults) Log.wtf("here grand result" , requestCode.toString(),) Log.wtf("here grand result" , grantResults.toString(),) if(requestCode == PERMISSION_REQUEST_ACCESS_LOCATION){ if(grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED){...
  • u

    user

    07/06/2022, 9:11 AM
    Stream two collections and collect a map based on common property I have looked around a bit but have not found a elegant solution. What I am trying to do is have a nice streamlined (pun intended) solution to create a map from two collections who have 1 shared property (an id of sorts). The map should be key-value of the matching objects. How I have done it for now is a forEach on collection1 and within a foreEach on collection 2 to get the matching model and then do an operation on it. I would like to create the map and then separately just do the...
  • u

    user

    07/06/2022, 9:11 AM
    How to adding a delay before the Countdowntimer starts? I'm trying to add a 2 second delay without locking the main thread every time a resume is called in the countdown timer. Without adding a delay, this below works perfectly, but when I add a delay, the main thread hangs. Every time I call resume and add delay with sendmessage delay, the thread hang. How can I add a 2 second delay just every time a resume is called without breaking the main timer ? abstract class CountDownTimer( /** * Real time remaining until timer completes...
  • u

    user

    07/06/2022, 9:11 AM
    Jetpack Compose: Best way to display a start screen only the first time you start the app Im currently working on an app that has a start screen where I want to input an unique code to add a device through firebase. After adding the first device the menu screen should appear after starting the app. I currently do that with two Activitys and a Shared Preference that checks if I have at least one device and redirects me from the StartActivity to the MenuActivity. Although that works fine, I dont think it is a good solution. Is there any other way to have a Start Screen that only...
  • u

    user

    07/06/2022, 9:51 AM
    How to write data to file in Kotlin A little while ago, i started learning Kotlin, and i have done it's basics, variables, classes, lists and arrays etc. but the book i was learning from seemed to miss one important aspect, reading and writing to a file, maybe a function like "fwrite" in C++ So i searched google, and yes, reading and writing bytes was easy enough. However, me being used to C++'s open personality, wanted to make a "kind of" database. In C++ i would simply make a struct and keep appending it to a file, and then...
  • u

    user

    07/06/2022, 10:11 AM
    Chaincall for each element in list Is exist elegant way to call function on every element in list to tie with next till the end? For example I have: val list = listOf(1,5,3,4) fun Int.foo(next: Int) = //some logic I want to generate this expression: val result = 1.foo(5).foo(3).foo(4)
  • u

    user

    07/06/2022, 10:31 AM
    How to set diplayName of a firebase User while using Phone Authentication I am creating an android massaging app where I am implementing Firebase Phone Authentication. When I am creating PhoneAuthOptions, I am not seeing any method to set User's displayName, and after the verification completion I need User's name to save it with phone number into Database. While setting up phoneNumber of the User, is there any I can set displayName of the User? val options=PhoneAuthOptions.newBuilder(mAuth) .setPhoneNumber(number)...
  • u

    user

    07/06/2022, 10:51 AM
    How to find the exception error point of the Image Button in this log? I've been struggling with this 'android.view.InflateException' issue in this log for a long time. The issue was that an activity composed of the Room database and Recyclerview could not be executed in API level 21/22. Of course, if I adjust the minSdk 21 setting higher to 23, that's it. But I didn't want to do that. I initially thought this was an issue with LinearLayoutManager or something because of the 'Caused by: android.view.InflateException' message in the log. Eventually I found out...
  • u

    user

    07/06/2022, 10:51 AM
    How do I use the name of the picture (It's already in "drawable") for use in the program? I tried to do it through "string" but it doesn't work. How to do it? var TestString : String = "test1.png" var TestId : Int = R.drawable.TestString
  • u

    user

    07/06/2022, 11:11 AM
    Android - Listening to incoming messages Am working on an android app that should be able to listen to incoming SMS and then show notifications. Later am using content://sms/inbox public List getAllSms(String folderName) { List lstSms = new ArrayList(); Sms objSms = new Sms(); Uri message = Uri.parse("content://sms/"+folderName); ContentResolver cr = mActivity.getContentResolver(); Cursor c = cr.query(message, null, null, null, null); mActivity.startManagingCursor(c); int totalSMS = c.getCount(); if (c.moveToFirst()) { for...
  • u

    user

    07/06/2022, 11:31 AM
    Formatting sensor event timestamp into date and time I am collecting Watch sensor data in a JSON file and I need to put a time stamp in the data to know when it was collected but I am getting time in milliseconds. How can I convert the sensor timestamp into a readable form of date and time and then put it as a JSON object in a JSON file to store the data?
  • u

    user

    07/06/2022, 11:31 AM
    Searching by Value in Redis in Spring Boot and Kotlin Let's consider we are in Spring Boot with Kotlin. For Redis queries, we're using a RedisTemplate dependency. Considering the following data class: data class Person ( val id: String, val name: String ) For saving we'll use: fun save(person: Person) { redisTemplate.opsForValue().set(person.id, person) } Then, is it possible to search by name, which is a property of the Person class? And if yes? How can this be done? Thank you in advance!
  • u

    user

    07/06/2022, 11:31 AM
    Jetpack Compose: Bottom Sheet not showing up as expected I have a scaffold that has a BottomNavigationView and the content. On one of my screens, I have a filter button that navigates me to the FilterScreen. FilterScreen is a bottomSheet composable. When I navigate to FilterScreen the result is : So as you can see when I click the filter button, the BottomNavigationView is hiding but the FilterScreen is not showing. Here is the code : val navController = rememberAnimatedNavController() val bottomSheetNavigator =...
  • u

    user

    07/06/2022, 11:51 AM
    Can't see the button in small screens I have a dialog implemented with BottomSheetDialogFragment, in which i have a list, an edit text and a bottom button that is has to be static. My problem is that in small screens the button and the edit text doesn't seem to appear, only the list. And in normal screens it works well and dont understand why. Ive tried a lot of stuff and no luck, so any helpo is appreciated Xml: Dialog: class MultiSelectionListDialog( private val...
  • u

    user

    07/06/2022, 12:11 PM
    How to filter in kotlin using predicates What i'm trying to achieve is using a filter function with dynamic predicates. What I did so far is creating a function that choose the best predicate: fun buildDatePredicate(dateFrom: LocalDate?, dateTo: LocalDate?): Predicate { if (dateFrom != null && dateTo == null) { return Predicate { myItem -> myItem.date.isAfter(dateFrom) } } if (dateTo != null && dateFrom == null) { return Predicate { myItem -> myItem.date.isBefore(dateTo) } } if (dateTo != null &&...
  • u

    user

    07/06/2022, 12:11 PM
    Unresolved reference: FragmentHomeBinding Unresolved reference: FragmentHomeBinding error when extending BaseFragment.
  • u

    user

    07/06/2022, 12:31 PM
    Why do we need to give default value inside getBoolean() in kotlin? I'm trying to put some data whose key: "isLoggedIn" and a value: true inside a shared preference file. I do it this way... sharedPreferences=getSharedPreferences(getString(R.string.preference_file_name), Context.MODE_PRIVATE) fun savePreferences(){ sharedPreferences.edit().putBoolean("isLoggedIn",true).apply() } and then if I want to retreive/store this key-value pair inside a variable it allows me only when I give the second parameter which is a value or defualt value like this. val...
  • u

    user

    07/06/2022, 12:51 PM
    Setting up a remote database for an android app Let's say I want to set up a database on a server I own, for a kotlin android app that will add and get datas from it (remotely). What solutions do I have ? I've seen that I should not communicate directly with the database, is it true ?
Powered by Linen
Title
u

user

07/06/2022, 12:51 PM
Setting up a remote database for an android app Let's say I want to set up a database on a server I own, for a kotlin android app that will add and get datas from it (remotely). What solutions do I have ? I've seen that I should not communicate directly with the database, is it true ?
View count: 6