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

    user

    06/28/2022, 11:11 AM
    Is it possible to toggle/view status of vpn from inside app? My app is done and working. The people who will be using the app are not the most computer literate. I am trying to show the vpn status or give a way to toggle the vpn from inside my app. The vpn has always on enabled but sometimes runs into a problem where it needs to be disabled and re-enabled. I am trying to create this process in the easiest way possible. The vpn currently in use is androids built in vpn. ( this may change later if I find another vpn that works better) Thank you for all...
  • u

    user

    06/28/2022, 11:31 AM
    Attempt to invoke virtual method 'void androidx.recyclerview.widget.RecyclerView.setLayoutManager(androidx.recyclerview..)' on a null object reference I want to write a good chat application with bottom navigation using Fragments. In ChatsFragment.kt I got a problem:

    enter image description hereâ–¾

    My fun onCreateView() in ChatsFragment: override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { usersRecycler.layoutManager = LinearLayoutManager(this, RecyclerView.VERTICAL, false) var userlist =...
  • u

    user

    06/28/2022, 11:31 AM
    Not getting my ID's from my XML File into my Kotlin file So, I'm new to this and I'd really appreciate a quick help. I'm making a chat app for android and my ID's ive given to EditText arent't being referenced into my Kotlin file. When I type them in, they aren't shown on the suggestion drop down and they have that yellow squiggle that says 'Parameter Not Used'. Here's the code from my XML file: and here's what i'm trying to do on my Kotlin file: package com.example.chatapp import...
  • u

    user

    06/28/2022, 11:51 AM
    how can i solve provide error causing by dagger-hilt? I'm using kotlin clean architecture + hilt in my project. this the error i got : C:\Users\ayoub\AndroidStudioProjects\cleanArchitecture_project\app\build\generated\source\kapt\debug\com\example\cleanarchitecture_project\presentation\App_HiltComponents.java:122: error: [Dagger/MissingBinding] com.example.cleanarchitecture_project.domain.repository.UserRepository cannot be provided without an @Provides-annotated method. public abstract static class SingletonC implements...
  • u

    user

    06/28/2022, 11:51 AM
    How to manage MVVM architecture when using socket feeds Hi already have android application which is in MVVM architecture, Now I am integrating socket for real-time feeds. I am confused here how to pass fit that real time data in that architecture. This Data is directly call inside fragment or pass to view model?
  • u

    user

    06/28/2022, 11:51 AM
    Android, manifest variables using C++ encryption (with NDK) I've just recently implemented NDK, and everything seems to work fine. Now.. I'm not sure on how to use the c++ method in the manifest, currenctly I'm able to use it via code by using a object that I created: object ApiKeyRetriever { init{ System.loadLibrary("api-keys") } external fun getGoogleKey():String external fun getFacebookToken():String external fun getDatabase():String external fun getFacebookProtocolScheme():String } I need it in the manifest for the...
  • u

    user

    06/28/2022, 11:51 AM
    Kotlin "Destructuring declaration initializer of type String must have a 'component1()' function" This is how I am calling the function :- val (ImageUrl: String) = uploadImage("ImageTitle", imageTitleUri!!) This is the function code:- private fun uploadImage(ImageName: String, ImageUri: Uri): String { val fileRef = storagePicRef!!.child("$ImageName.jpg") val uploadTask: StorageTask uploadTask = fileRef.putFile(ImageUri) var imageURL = "" uploadTask.continueWithTask(com.google.android.gms.tasks.Continuation { task -> if...
  • u

    user

    06/28/2022, 12:11 PM
    I need to get list with an argument private fun getRadResultList() { safeLet( arguments?.getString("referenceVisitId"), arguments?.getString("facilityId") ) { referenceVisitId, facilityId -> viewModel.getRadResultsWithId(referenceVisitId, facilityId) } } This is my previous code. The number of arguments requested by the function is now one. How do I return the facilityId in getRadResults() private fun getRadResultList() { safeLet( arguments?.getString("facilityId") ) { facilityId...
  • u

    user

    06/28/2022, 12:31 PM
    What is a proper way to connect with a media browser who is currently playing audio? I am currently working on an app that includes an audio media player. What I want to accomplish is to start a track on a fragment that represents the UI of the media player (like a bottom collapsed media player), and then when I click on this media player layout, I want to start an activity that will display the media player expanded (including skip buttons and progress bar). Right now, whenever I click on the above-mentioned layout, the activity starts but the track starts all over again...
  • u

    user

    06/28/2022, 12:51 PM
    Querying by value in JSONB field in h2/postgresql I have following json field in entity: {"uuid", "uuid2"} and I want to use @Query to find an entity which contains given uuid in this field. I have found a solution for postgresql (which we are using), but when I try to test it using h2 I get Function JSONB_EXISTS not found exception. Is it possible to make it work with both postgresql and h2 using same query? How I am creating a query (this works fine for postgresql, but not for h2): @Query( nativeQuery = true, value = "SELECT * FROM...
  • u

    user

    06/28/2022, 12:51 PM
    kotlin - password validation I need a password validation regex in kotlin characters length: with 8 to 16 combining at least two types of alphabet, number, and special characters "^(((?=.*[a-zA-Z])((?=.*[a-zA-Z])|(?=.*\\d)|(?=.*\\W)))|((?=.*[a-zA-Z])((?=.*\\d)|(?=.*\\W)))|((?=.*\\d)(?=.*\\W))).{8,16}\$" above regex, "abcdabcd" have to false, but true. "^(?=.*[0-9a-zA-Z])(?=.[!@#\$%^&])(?=\\S+\$).{8,16}\$" The above regex is a combination of two or more letters, including special characters, or upper and lowercase...
  • u

    user

    06/28/2022, 12:51 PM
    Jetpack Compose: How to center an item in LazyVerticalGrid? I have a LazyVerticalGrid composable that shows my items. I want to show an error message with a button in the center of LazyVerticalGrid when an error has occured. Here is my error item and my LazyVerticalGrid: ErrorItem @Composable fun ErrorItem( message: String, modifier: Modifier = Modifier, onRetryClick: () -> Unit, ) { Column( modifier = modifier .padding(dimensionResource(id = R.dimen.dimen_8)), horizontalAlignment =...
  • u

    user

    06/28/2022, 1:11 PM
    How create extension function ifNullOrEmpty? I want to create a function like ifEmpty() of Kotlin that will also check for null: ifNullOrEmpty{ //some code if null or empty } How can i do this? And does anyone know what the code below is called? : R where C : CharSequence, C : R Example of Kotlin ifEmpty() function. @SinceKotlin("1.3") @kotlin.internal.InlineOnly public inline fun C.ifEmpty(defaultValue: () -> R): R where C : CharSequence, C : R = if (isEmpty()) defaultValue() else this Thanks and have a nice day!
  • u

    user

    06/28/2022, 1:31 PM
    Repeat request if get 202 code Android Kotlin RxJava 2 I need to implement a request retry if 202 code comes using RxJava 2, the problem is that when I try to do this, then with 202 code the response from the server is empty, and with a successful response, the desired model comes, so with 202 code I get an error, and further processing by the response code does not occur. @GET("dogs") fun getDogs(): Observable This is response processing. private inline fun Observable.handle202(): Observable { return this .flatMap {...
  • u

    user

    06/28/2022, 1:31 PM
    Parse json String with forward slash in Gson I have to retrieve data from a rest api which just returns a String without any json format which also contains a forward slash which shouldn't be escaped. When I for example try to parse this: Gson().fromJson("foo/bar", String::class.java) I get the following error: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 5 path $ But when I then try the setLenient like this:...
  • u

    user

    06/28/2022, 1:51 PM
    Ktor Server + Vue single page application I'm trying to create a REST API with panel admin. I have no problem with the API, but I have no idea on how to integrate Vue into the project. I can't find any example, the only example from ktor doc is with a react-app. I don't know how the vue package should be. In ktor I have that: routing { singlePageApplication { vue("vue-test") defaultPage = "public/index.html" } } And vue-test is a project created with WebStorm. I only copied it in the...
  • u

    user

    06/28/2022, 1:51 PM
    Activity takes a decade to open because I get Firebase queries at on Create private fun getAngryMovies() = CoroutineScope(Dispatchers.IO).launch { try { val querySnapshot = allMoviesCollectionReference .whereEqualTo("type", "Angry") .get().await() for (document in querySnapshot.documents) { val movieObj = document.toObject() if (!innerAngryMovieList.contains(movieObj)) { innerAngryMovieList.add(movieObj!!) } } showContent = true...
  • u

    user

    06/28/2022, 2:11 PM
    What is the name of the channel from Java/Kotlin to Flutter (not the way around) Flutter has the MethodChannel for sending data from Flutter to Java/Kotlin. We can also return values in these calls. But what if I want to return data at random times from Java/Kotlin to Flutter? I remember there is a kind of channel to send data from Java to Flutter, but I forgot its name
  • u

    user

    06/28/2022, 2:11 PM
    Proper argument type for scalar JSON graphql What is proper input argument type for scalar JSON @Argument? As the result I have all arguments in my map when I need only my:

    https://i.stack.imgur.com/NN8S1.pngâ–¾

    My schema.graphqls scalar JSON type Product { id: ID description: JSON! name: JSON! price: String } type Mutation { addProduct(description: JSON!, name: JSON!, price: String!): Product } I have controller with mutation: @MutationMapping fun addProduct( @Argument name:...
  • u

    user

    06/28/2022, 2:31 PM
    Convert plane text with forward slash from rest API to String with Gson I have to retrieve data from a rest api which just returns a plane String without any json format, which also contains a forward slash which shouldn't be escaped. When I for example try to parse this String: foo/bar which I can't change with this GsonBuilder: val gson: Gson by lazy { GsonBuilder() .registerTypeAdapter(LocalDate::class.java, LocalDateSerializer()) .registerTypeAdapter(LocalDate::class.java, LocalDateDeserializer())...
  • u

    user

    06/28/2022, 2:31 PM
    How to include kotlin.test properly via Maven? Our team is making first steps into Kotlin and I'm about to to migrate a test. I tried a first example from mockk (https://github.com/mockk/mockk/blob/master/mockk/common/src/test/kotlin/io/mockk/it/InjectMocksTest.kt). For some reason it seems I'm not able to use kotlin.test although I have added it via maven. Do I have to include any other modules?...
  • u

    user

    06/28/2022, 2:31 PM
    Recyclerview not showing items Kotlin My App is just shows an Empty Screen and recyclerView is not showing anything or is not working but there are no compile time or run time errors. It would be great help if I get an answer ... I have been making an app that uses a RecyclerView but its not showing any thing..why contents of the recycler view have not been showing up.my codes are bellow Here is My FeedFragment, Adapter //Fragment @AndroidEntryPoint class FeedFragment : Fragment(R.layout.feed_fragment) { private var...
  • u

    user

    06/28/2022, 3:11 PM
    Drag and drop cards to folders android Hii In my UI the above one is Card layout. And below is recycler view of folders. User Needs to drag card to bottom near by one folder. And then folder need to animate and come up. Then I have to copy the image to that folder. Then folder again need to reset to original position. Android Kotlin can anybody help ?

    https://i.stack.imgur.com/tVJ2f.jpgâ–¾

  • u

    user

    06/28/2022, 3:31 PM
    Consider defining a bean of type 'com.fasterxml.jackson.databind.ObjectMapper' in your configuration I know this is a sort of common question, I saw this one and a few others, what is strange to me is I have been using ObjectMapper for years now and this is the first time I am encountering this error, my code like this: import com.fasterxml.jackson.module.kotlin.* import com.fasterxml.jackson.core.* import com.fasterxml.jackson.databind.ObjectMapper...
  • u

    user

    06/28/2022, 3:31 PM
    ANDROID - Jetpack Compose: how to implement theme settings? I'm having hard times trying to implement a preference who switch the application theme. Normally I would be able to do it with XML but with Jetpack Compose I saw that the best practice is to use DataStore (https://developer.android.com/topic/libraries/architecture/datastore) Someone please, can explain me from scratch how to store a preference and change the whole application theme...
  • u

    user

    06/28/2022, 3:31 PM
    Should I use remembercoroutinescope or viewmodelScope? Which one is right for my scenario? In my example, I need to perform a process and if it is successful, the app should navigate to the next page. The first approach uses viewmodel scope on a non suspend function and then uses a callback to let the UI know that the process is complete. The second approach is declaring a coroutine scope in the UI level and then making the viewmodel a suspend function. Which would be the right approach for my scenario? What's the advantage of each approach over the other? Is there a particular...
  • u

    user

    06/28/2022, 3:51 PM
    Only on Windows: "Socket fail to connect address already in use" (Exposed, Koin, Flowables) I only encounter this problem when I am on Windows and actively work on the project with IntelliJ Idea. When I deploy it onto the Linux machine everything works fine. I already updated exposed, but it didn't help. The errors come in very quick succession and make using the app impossible. Additional libraries I use: Flyway, RxJava, Koin, Exposed Database connection: fun mariaDBModule(databaseConfig: DatabaseConfig): Module { val database = Database.connect( url =...
  • u

    user

    06/28/2022, 4:31 PM
    registerForActivityResult resultCode get 0 value I'm trying to use registerForActivityResult but the result of it is 0, which mean that it doesn't get the result from the activity. The code was working perfectly last month when i did it, but i don't know why it made the error today, i tried to check for error in the code, but i dont think there is one. Here is the function to use the camera : private fun UseCamera() { val takePictureIntent = Intent (MediaStore.ACTION_IMAGE_CAPTURE) val imagePath =...
  • u

    user

    06/28/2022, 4:51 PM
    Kotlin Multiplatform : add a Kotlin/Native as common code I want to create a Kotlin project compatible with Android and Desktop. This project needs to bind to a C library. The way I understand it, I should create a Kotlin multiplatform project, and have a common code which wraps the C library using JNI. However, Kotlin/Native allows a way easier interop with C libraries, so I'd like to use that. But it seems like Kotlin/Native is a platform (equal to eg jvm or android), so it can't be used as a common code. Is there a way to do what I want? I...
  • u

    user

    06/28/2022, 5:11 PM
    Updating the GPS position of a device in an Android app I have a tiny Android app written in kotlin, it gets the location of the device. Almost all the code is hereafter (I did not include the UI) : class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) gpsPermissionCheck() val client = LocationServices.getFusedLocationProviderClient(this) client.lastLocation.addOnSuccessListener {...
Powered by Linen
Title
u

user

06/28/2022, 5:11 PM
Updating the GPS position of a device in an Android app I have a tiny Android app written in kotlin, it gets the location of the device. Almost all the code is hereafter (I did not include the UI) : class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) gpsPermissionCheck() val client = LocationServices.getFusedLocationProviderClient(this) client.lastLocation.addOnSuccessListener {...
View count: 4