Category "kotlin"

Post request a raw json with Ktor client

I want to make post request with Ktor but I get Error 400. the curl looks like this : curl --location --request POST 'https://api.jdoodle.com/execute' \ --heade

Cannot deserialize XML object to data class using JacksonXml

I'm attempting to deserialize this xml string: val xml2 = """ <id>3</id> """.trimIndent() to this data class @JacksonXmlRootElement(localName = "

LazyColumn that respects MotionEvent.ACTION_SCROLL

How to force compose' LazyColumn to act like traditional scrollable elements like RecyclerView or ListView? Useful when want to scroll with mouse, e.g. with vys

kotlinx.serialization.json.internal.JsonDecodingException: Polymorphic serializer was not found for missing class discriminator ('null')

I am using sealed class to handle api response. I am trying some code but getting some error of serialization. I tried this solution as well but it not working.

Kotlin Mockito Generics

Suppose my class is: open class TestThis{ @Autowired private var myService : MyService? = null fun doMyFunction(){ val result = myService.d

How to observe ContentProvider changes for coroutine flow

I have a flow to fetch data from database via content provider. fun getDataFlow(): Flow<Result> { return flow { emit(Result.Loading) // f

Is there a way to force using annotation only on a var property

I'm making an annotation processor for encrypting personal data due to law. So in order to encrypt those field it should be able to set new value so I want my a

Hilt Unsupported metadata version in Kotlin

I was tried to run my code in Kotlin 1.5.10 With plugin as plugins { id 'com.android.application' id 'kotlin-android' id 'kotlin-kapt' id 'dagger.hilt.android.p

How to make item selectable in recycler view and use it?

I have followed android developer documents to create the recycler view. But now I would like to make the item selectable. Currently have created itemAdapter.kt

Get contacts which have same phone number stored in phone number list in firestore

this is my first time trying Firestore. I have a collection named users, where every user is a UID and every user has fields (name, phone, and contacts (array))

Error: Hilt Fragments must be attached to an @AndroidEntryPoint Activity

Fragment is not loading in Unit Test. Code: @RunWith(AndroidJUnit4::class) class DataFeature { @Test fun testEventFragment() { val fragmen

How to call a element from Layout without use findViewId() in Kotlin?

I didn't know this was possible, but I was following an example and I see this piece of code: import kotlinx.android.synthetic.main.activity_main.* class MainA

CameraX doesn't save the pictures

I'm trying to use the example app from google codelabs to implement the camerax application, but i dont know, why it doesnt save the pictures correctly. private

Kotlin Data Class Property: Multiple types

In Kotlin, can a property of a data class have multiple types? For example: val CurrentValue: Double?|String or val CurrentValue: String|Array? I cannot find it

How to get Context in onViewCreated

I'm attempting to configure a RecyclerView adapter and I have a line of code val decorator = AppCompatResources.getDrawable(context, R.drawable.decorator) This

Many third party libraries not working with android studio bumblebee update

Recently I've updated my android studio to bumblebee. With this update, many of the libraries I've used in artic fox is not working. some of them is following:-

Room DB ANR Input dispatching timed out

I am doing a db get operation for my cart page which has multiple tables. I have mapper class which has all the relations with all the tables. I have used corou

CPU, RAM stress android

I have a task to compare the performance of Java and Kotlin programs. I would like to measure CPU memory and RAM usage. I read somewhere that a good idea for CP

Kotlin: Problem with List Filter by Multiple Conditions

I'm trying to match two lists to another. In one list are items of crypto trades, the other contains so called candlesticks, which represents a price of crypto

Could not compile build file, startup failed in android studio

1 Build File "C:\Users\Macking Crasher\Desktop\Nasmus\gl/1a.gradle Tanw: 19 Could not compile auslaste "C:users\Macking Crusher\Desktop\nashoploustd.greate'. st