Category "kotlin"

Kotlin - Conditional method name with same parameters (mitigation of code duplication)

Let's consider this code examples in Kotlin: if (isFooBar) method1(arg1, arg2, arg3) else method2(arg1, arg2, arg3) // Or larger example when(enumBar)

Android APP crashes while Loading the ads

I am trying to make a social media application. I am trying to insert ads in between the posts. In the below code when running app crashes while executing the a

How do I reduce the size of a photo when uploading a photo to Firebase storage?

I want to reduce the size of the photo when uploading photos to Firebase storage. There is an error in my codes. I wrote a method for sizing. Can you help? (kot

Is there difference between `Class.newInstance()` and `Class()` in Kotlin?

Is there a any functional difference in Kotlin between those? class Foo { companion object { fun newInstance() = Foo() } } // Create new instance s

Automatic call Picker android kotlin

How can I create an app that can take incoming calls automatically in kotlin android 10 and above anybody I have tried using the BroadcastReceiver() class but i

what's difference between ModalBottomSheetLayout and BottomSheetScaffold in compose?

Simple question, what's difference between ModalBottomSheetLayout and BottomSheetScaffold in compose? if they both do the same things so what's the difference ?

How do I persist authentication state in my Kotlin firebase app?

I am building a kotlin app using FirebaseAuth and I want to add some custom rules to keep the user signed in for a time even if they are not using the app. All

Sending Data between Fragments using Shared Viewmodel and SharedFlow

I'm very new to Kotlin Flows. As the title suggests I basically have 2 Fragments that Shares a ViewModel. I want to send data between them using SharedFlow as a

Property with return value in Java/Kotlin?

This is a pretty basic question, but I haven't been able to find any answer on SO yet. I'm just curious, is there a corresponding way in Java or Kotlin to write

Why is Spring @Transactional unreliable with AspectJ?

TLDR: this project reproduces the issue: https://github.com/moreginger/aspectj-no-tx Edit: Above now reproduced without jooq i.e. using plain JDBC. Edit: Spring

Why I need to explicitly add the fragment and activity dependencies in android?

I don't understand, while learning through a codelab in android they want me to add the following dependencies to the android build.gradle implementation "andro

drawing a speech bubble using canvas in jetcompose

i want to draw a speech bubble using canvas in jetcompose but i dont know how to draw an arrow at bottom end of the Rectangle this is my code: @Composable fun D

LazyColumn with ConstraintLayout in android jetpack compose

I'm going to put a label on the top for each column and a LazyСolumn on the bottom. As follows. However, when I filled it out, the screen other than I ex

How to test async function in Mockk Kotlin

I want to test this function. suspend fun fetchTwoDocs() = coroutineScope { val deferredOne = async { fetchDoc(1) } val deferred

When to use let/run/apply/with/also when an object is null?

I want to run a block of code depending if the variable is null or not, but I still don't know when to use let,run...etc. I want something like this: myVar?.xxx

Quarkus: connect to cloudsql db (gcp) with native image

I've set up a prod configuration for my datasource to connect to a GCP MySQL instance, basically following this tutorial: https://quarkus.io/guides/deploying-to

Android Studio memory profiler have some serious memory issues

I am trying to fix some memory leaks in my apps but I am always fighting with memory profiler instability itself instead of being able to focus on my task. Inte

java.lang.IllegalStateException: No request transformation found: XYZ in ktor

Hey I am working in ktor. I am getting weird issue and I am trying to find the issue, but unable to get the proper reference. androidMain AndroidHttpClient.kt p

Kotlin sort one List with key and Enum with key and order

I receive data from Request information as list data (List) below code. That data has a "key" parameter by which I want to sort it. data class ApplianceSetting(

Can't show/hide menu items on Kotlin - Android Studio

my application has a menu of 3 options, and what I want is that according to a condition that I define, it shows only 2 options, or it shows 3. I have tried all