Category "kotlin"

Is there a way to auto-cast string to enum?

Is there a way to auto-cast or auto-convert strings to enums? playground enum class Direction { north, south, west, east } fun main() { val d: Directio

Kotlin methods accepting inline classes as parameters - how access from Java?

Let's say I have: inline class Email(value: String) and fun something(email: Email) now if I want to call something() from Java I can't. Because any method

Execution failed for task ':app:mapDebugSourceSetPaths'. > Error while evaluating property 'extraGeneratedResDir' of task

I've checked this answer: https://stackoverflow.com/a/34834772/13519865 It tells us to remove this line apply plugin: 'com.google.gms.google-services' Removing

Sending Data in Body in retrofit kotlin

I am using retrofit for calling the API i have to send the data in Body as we send in Java @Body but don't know how to parse the data... { "appType": "EXTERN

Add 2 or more constructors in kotlin

how to add 2 or more constructors ?? i know the use of data class in kotlin, but i am not getting what exactly this keyword is in kotlin and why we have to put

Flow message not delivered in unit test

I have a consumer that reads messages off MutableSharedFlow (which acts as an EventBus in my application). I am trying to write a unit test to show that passing

moving from fragment to bottomNavitem, Onclick of that bottomNavitem, it opens that fragment again i need to open start fragment again,without delay?

i tried to open bottomNavitem from fragment with this code on ,it opens bottomnavitem ,on comming back same bottomnavitem it open same fragement while i need to

Suspend function 'callGetApi' should be called only from a coroutine or another suspend function

I am calling suspended function from onCreate(...) override fun onCreate(savedInstanceState: Bundle?) { ... ... callGetApi() } and the suspended

MutableStateflow Value Vs Update vs Emit

Let say I have a MutableStateFlow variable. What is the main differences and usage of the three cases mutable.value = 1 mutable.emit(2) mutable.update {3}

Android studio Composable Preview Render problem

I am having this issue When previewing composable from file. This is the code I made in other kotlin file. package com.example.movieapp.screens.home.details im

Kotlin textview to scroll in both directions

I'm trying to setup a textView in Kotlin to scroll in both directions (ie horizontal and vertical). That is, I want long lines to run off the right side, and us

I am new to flutter and dart so i have being trying to use my phone to test the demo flutter file in android studio but i keep getting this error

FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':app:compileDebugKotlin'. Could not resolve all files for configuration ':

Should I turn my Activities into Fragments?

I went to the YouTube Academy for Kotlin Android Development and created a semi complex app with Google FireBase, I have hit a roadblock in some code using an E

Classifier does not have a companion object, and thus must be initialized here

I have an Activity where an interface is declared and I have a ViewModel class which has overridden interface and want to invoke the method of interface from Ac

How to set multiple alarms in kotlin?

so I'm new to coding and I'm making an app for Muslims prayer times and I want an alarms to be set repeatedly on these times I tried to many things but It does

ViewModel updates on screen rotation

I've created a simple project to study Kotlin and Android architecture https://github.com/AOreshin/shtatus The screen consists of RecyclerView and three EditT

Youtube video playing intent only works if Youtube is not open yet

I would like to send intents for a continuous stream of videos, but all intents, except for the first one (sent with youtube closed) seem to be ignored, and you

Android Notification MediaStyle Ignores Ongoing Flag

I am attempting to employ a MediaStyle notification in an audio Android application as discussed in the audio app documentation as well as in the media style do

Rest Api SSL on tomcat server

Setup: I have setup a front-end(Next.js) and backend kotlin-api. I use Cloudflare with SSL turned full on. I have setup SSL using certbot on both of these. This

I cannot concatenate a variable + string + variable this line of code gives me a error "None of the following functions can called with the argument s

I'm a newcomer in this, and I'm learning kotlin in android studio, and I'm stacked in this error, "None of the following functions can be called with the argume