Skip to content

Tag: kotlin

How rewrite Java generec’s into Kotlin?

I have java class and I need to rewrite it in kotlin. But I can’t rewrite generics into it. Java class: My Kotlin class Sign (1) I marked the my problem area by my opinion. But maybe the problem is somewhere else. Answer Kotlin’s <out FlagFilter> is not equivalent to Java’s <T extends FlagFilter>. Using out at a generic declaration

How to set the width and height of a layout in Android?

I have this ConstraintLayout: lateinit var myConstraintLayout: ConstraintLayout I try to set its width and height to match its parent via code, like this: But I get error androidx.constraintlayout.widget.ConstraintLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams Why? How do I fix this? Answer The LayoutParams need to be the LayoutParams type of the parent ViewGroup. It is the parent ViewGroup that actually

registerForActivityResult is not working in Flutter

I’m trying to launch context from android MainActivity class to flutter. code : and then calling the method launch code : and then I call this method from flutter by creating a channel between flutter and android and invoke it : when I press the sign in button it shows me this exception : Attempt to invoke virtual method ‘$ApplicationThread

How to parse this date/time in Java/Kotlin?

I have this NMEA timestamp: 120722202122 and I want to parse it. I tried Playground but I get an Exception: I don’t know what the Exception wants to tell me or what my pattern should look like. Answer I assume you’ve probably meant the day of the month d, not the day of the year D. In your pattern, you’ve

Google Play Console: ‘Your app signing key’s encryption strength does not meet Google Play’s recommended minimum standard’

I enrolled my apps in ‘Google Play Signing’. Now I see in the console the following message: I thought that it is due the fact that all my apps were initially signed with the same release key (that I uploaded to Google Play Console during the enrolling procedure to Google Play Signing). So I thought that Google Play sees that

How to remove underline in hyperlink

I have a TextView on my ‘settings’ activity: I have defined my URL on the string. On my settings.kt page I have the following code onCreate: From what I have found, I need to add a ‘spannable’ in relation to the above (settings.kt) but I’m not sure how to apply it, as everyone adds hyperlinks differently. Answer As you mentioned

Korge gradle setup for JVM target

I want to try the Korge libs on the JVM. I used the Korge IntelliJ plugin to create a new project. My build.gradle.kts looks like this : I’ve copied the commonMain code into the jvmMain folder and running the project with the runJvm command. I’ve looked into the examples on the korge doc and github, but i can’t manage to

Null pointer Exception in Android when using Glide

Here is the logcat output From my logcat the exception occurs when using Glide to load image. Line 100 is .into(uImage) Answer As far as I understand, you’re initializing the Views of BottomSheet wrong. If I’m not wrong, you’re trying to show this BottomSheet inside an Activity, if yes, try the below code:

Query on distant/not directly related entity

I’m trying to create a query with a where clause on a not directly related table. My table/entity structure looks like this: I have got an entity Entity with a ManyToOne relation to Relation. Relation has a ManyToMany relation to DistantRelation. I have a JpaSpecificationExecutor<Entity> on which I call findAll() with a Specification<Entity>. How do I setup my entity and/or