Skip to content
Advertisement

Tag: kotlin

Getting a map and collectors error in kotlin function

I am trying to convert this java function to kotlin. I end up with the following: However on the line I get the following error: Answer You don’t need stream() in kotlin. The collections classes in kotlin provides all methods you need. (e.g. map, distinct, toMap). Here is the kotlin way to write your function: I don’t know the nullability

How to track a touch on the screen

I want to write a penalty shootout application, now I have set up the background and added the ball and the goalkeeper to the map. How do I make it so that when I tap on the screen, the ball follows my touch on the screen. How to do this? How to track the touch on the screen and enter

Convert Java loop to Kotlin [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 9 months ago. Improve this question I’m studying implementation with Kotlin. When I implement Kotlin version by below situation, I can’t imagine cool way. Above code is Java version Above is

Run background service only when phone is in use

I’m trying to make an android app that fires a background intent to “ping” a server with a post request about every 2 minutes (by default, interval is user-configurable). I absolutely need to avoid the service running when the phone is not in active use, and I need it to not defer the service like an AlarmManager would. If it

return throw exception in Kotlin

I have the following problem, I can’t return this exception. It’s giving an error 500 and doesn’t run this exception. I wish that when I entered the if it would already return this custom exception. KOTLIN JAVA Answer You need to use RestControllerAdvice or ControllerAdvice like

IllegalArgumentException: Unable to create @Body converter for class

Whenever I try to create a request with Retrofit it fails. The strange thing is that it worked before, I didn’t change anything about the code. Now months later it doesn’t work anymore. I’m getting the following error: IllegalArgumentException: Unable to create @Body converter for class apis.Config (parameter #2) I tried changing from Gson to Moshi but it didn’t solve

How to disable notification sound with keeping heads up notification?

I want I’m noob for android. My app displays heads up notification. Now, my app always ringing when it listen notification regardless silent mode ON/OFF. I want to do next things. Disable notification sound with keeping heads up notification in silent mode. Thanks for your help. Problem My app ringing when silent mode. code MainActivity.kt PushNotificationListenerService.kt things I tried Switch

Advertisement