Most voted "kotlin" questions
Kotlin is a statically typed programming language compatible with JVM and Javascript.
Learn more…234 questions
Sort by count of
-
2
votes1
answer88
viewsHow to interrupt a cycle of "whiles"?
Well, I’m going to give a very abstract example in order to be able to express my doubt more simply I have following code: while(a>b){ // Meu while principal while(c>d){ while(e>f){ } } }…
-
2
votes1
answer253
viewsHow to generate a value containing the "last Friday of the month" using Java Localdate?
I am receiving data from a CSV file with some data, and one of these data contains random dates in the following format: mm/YYYY. I have a parameter private LocalDate date. And from the generated…
-
2
votes2
answers373
viewsDifference between Arraylist and Mutablelist in Kotlin
Arraylist is a changeable list and Mutablelist is also, but what is the difference between them?
kotlinasked 5 years, 7 months ago Júlio Moura 311 -
2
votes2
answers56
viewsData Binding Formatted Strings Losing Format
Apparently Data Binding for formatted strings does not work properly. For example: <string name="minhaString">Você tem um limite de <b>%s</b> reais.</string> If I use Binding…
-
2
votes0
answers130
viewsWhy does an integer not format correctly (Kotlin/Java)?
I use the Android Studio 3.4.2. I ran a test code that generates a very strange format. This excerpt was placed right after the beginning of the onCreate. And it’s a pure integer! fmtFloat =…
-
2
votes1
answer218
viewsMethods for changing orientation of the UI Automator Framework do not work
The methods setOrientationLeft() and setOrientationRight() below simply do not work, both on emulated devices and on physical devices. I would like to know if there are any rules for using sponges…
-
2
votes1
answer249
viewsKotlin - How to wait for the user to return a function called inside the while loop
I have an algorithm that via console helps the user in sorting a list of items, it works well for the console (code below), but I’m adapting the interface to become an app (as print) I wanted that…
-
2
votes1
answer42
viewsFiltering a list with elements contained in another list
I have the class class estruturaPosicaoXY(val x: Float, val y: Float) {} then fill out a list of that class through the method: fun mapearXY(x: Float, y: Float): List<estruturaPosicaoXY> { val…
-
2
votes1
answer37
viewsSubstring does not return empty string
I have the following text file called fullResponse <Sum> [stat]player_ammo_restored = 3447 <Sum> [stat]player_climb_assists = 2102 <Sum> [stat]player_climb_coops = 2612 <Sum>…
-
2
votes1
answer42
viewsReceive response Okhttp KOTLIN
I am trying to process the data received from an external API. I have two files, one responsible for making the request, and the main one to call the function, but I can’t pass the data return to…
-
1
votes1
answer131
viewsKotlin - How to play the effect of "lateinit" on a "var" of an interface?
I have an interface called UserManager who owns a var of the kind User interface UserManager { var user:User /* ... */ } and a class called UserManagerImpl implementing UserManager class…
-
1
votes1
answer227
viewsHow to add Firebase data to a Recycleview and show on Android screen with Kotlin?
How to bring this fire list to the cel screen? val store = Shop("Fique Linda", "Temos o melhor!", R.drawable.storefiquelinda) val dataBase = FirebaseDatabase.getInstance() val myRef =…
-
1
votes0
answers282
viewsHow to have a searchview of material design?
I need to have a Toolbar with the menu items inside, search icon and voice. Like the one in the picture: I have the code to Activity override fun onCreateOptionsMenu(menu: Menu): Boolean {…
-
1
votes2
answers35
viewsProblems handling Vector Asset
Android Studio is returning this error when I add images to my project, but the selected images are the native IDE icons.…
-
1
votes2
answers528
viewsWorking with custom alertdialog layout
I created this layout, so I could work with this alertdialog. I created it, because I have to record the states after the click and also, when opening the dialog, I can get the value that was marked…
-
1
votes1
answer376
viewsKotlin error does not find bytecode for lambda Function: "Failed to find byte code for java/util/Function/Biconsumer"
When I try to run my app on mobile (emulator happens the same), the following error occurs: Error:FAILURE: Build failed with an exception. * What went wrong: Execution failed for task…
-
1
votes0
answers274
viewsDifference between method and function?
Because in Java it’s called method and in Kotlin it’s called function, it’s just a different nomenclature, or is there a significant difference? Java: public class Teste { public static void…
-
1
votes0
answers25
viewsReflections with Kotlin
I need to compare a Kparameter with a Kclass, know if the type of the parameter is equivalent to my Kclass. So far I have not found a saint to do this, someone has my solution?
-
1
votes2
answers256
viewsWhat tools should I use to create an android app
I’m starting in mobile development that will be done in Java or Kotlin and my question is what tools I can use both in the design part and in the database which are the main technologies ?
-
1
votes1
answer85
viewsInjecting dependencies beyond Activity and Fragment?
It takes something special to inject a dependency with Dagger into an Android project other than Activity, Fragment, Service etc???? Example, if I have: Activityman -> Fragmentlistcake ->…
-
1
votes0
answers74
viewsProblem creating android unit test with Rxjava and Mockito
The test is about making the assertions that the methods are called when the execution is successful, but an error is occurring that I cannot solve. My class: class LoginActivityPresenter(private…
-
1
votes1
answer30
viewsPlugin to create runtime variable instance builder
I need to create some tests using variables already instantiated at runtime, and instead of manually mounting, object by object, attribute by attribute, I would like some tool that automates this…
-
1
votes1
answer265
viewsUser authentication with H2 database in Kotlin Spring Boot Application
Problem: Authenticate user using H2 database in Spring Security Context: The application is made using Spring, the user class is this @Entity data class Usuario( @NotEmpty var nome:String = "",…
-
1
votes2
answers114
viewsIs it worth measuring performance between Java x Kotlin applications?
Going through the Google Developers documentation, I found something pretty cool like: Measure app performance with Android Profiler But knowing that Java and Kotlin are interpreted by the JVM, I…
-
1
votes0
answers208
viewsHow to receive messages from firebase console on android in the background?
I have an app that sends notifications from the firebase console and my notifications don’t arrive on my phone when they’re in the background but when they’re in the foreground with the app open the…
-
1
votes1
answer35
viewsConvert Tripledescryptoserviceprovider to javax.crypto.Cipher
I’m needing to convert a VB encryption method to Kotlin, however, the results are giving different. In Vb is implemented as follows: Public Shared Function MD5Hash(ByVal value As String) As Byte()…
-
1
votes0
answers99
viewsWhat am I doing wrong using LET (Kotlin)?
I’m using retrofit and onResponse, when I try to get body information with (Let), the internal code is not executed. response?.body()?.let { Log.i("Info", "Cidades: " + it.size) } If you try it like…
-
1
votes1
answer83
viewsSignature of a generic function in Kotlin
I was watching the part about Generics and I’d like to know why the fun <T> addToList(vararg arg : T): ArrayList<T> { and not the fun addToList(vararg arg : T): ArrayList<T> {…
-
1
votes1
answer53
viewsHow to filter to show only required fields in a class using Gson
I’m using Gson to work with json, let’s say I have this class class Track( @SerializedName("id") val id: Long, @SerializedName("name") val name: String, @SerializedName("modality") val modality:…
-
1
votes2
answers43
viewsHow to check if there is an update in google play for my application
I have an app published on google play, where now I have the need to check if there is an update for it, in case there is I need to do a routine. Is there such a possibility?
-
1
votes1
answer84
viewsHow to get the default value of a type in Kotlin?
I’m coming from C# and starting working with Kotlin (Android). In C#, if I want the default expected value for a type I should call it as in the example below: class Foo {} class Main { public…
-
1
votes3
answers76
viewsHow to Save to Seekbar Android Sqlite Value Database
I am trying to register values in the database in Kotlin from Seekbar, from Datepicker, Radio Group in my Cadastroscrolling.kt I can play the visualization of age // definindo SeekBar seekbarIdade =…
-
1
votes1
answer33
viewsValue insertion problem in an array/list
I am trying to insert a number into a list/array but on condition if are you saying: No get method providing array access import java.util.Scanner fun main(){ val input = Scanner(System.`in`) var…
-
1
votes1
answer103
viewsReturn true when Bigdecimal variable is different from null, otherwise return false
I have a type attribute BigDecimal x. I need to call a method exampleMethod(). I would like to pass the parameter true or false depending on whether x is null or not, as in the example below: val x:…
-
1
votes0
answers29
viewsSwitch web application port with Kotlin in Intelij
I’m using Kotlin on Intelij along with Vertex and Jboss. I want to change the default port of my application. I have tried to put in the VM Options of the Inteli run Configurations a different port,…
-
1
votes0
answers239
viewsunit test with mocked Json
I am trying to create a test from a json file that I have with the mocks of the Api response. But when I run the unit test the variable stream the return is null, ie it can’t read the file resulting…
-
1
votes1
answer311
viewsError implementing Room Persistence Library + Kotlin
When trying to run an application developed in Kotlin with ROOM Persistence Library I have the following return: java.lang.Runtimeexception: cannot find implementation for…
-
1
votes0
answers288
viewsHow to take a variable from another class in Kotlin?
I want to take a variable from one activity and use it in another class. This variable will be filled by a user in an editText called editTextSerie override fun searchSeries(listener:…
-
1
votes1
answer144
viewsRetrofit Answer returning null with code 406 Not Acceptable
Talk personal, I’m using Retrofit2 with Kotlin and I’m trying to perform a POST request where a Json will be returned. The request is made and the server part works (register the user), however when…
-
1
votes1
answer32
viewsMutablelist<Int> cannot be Invoked as a Function. What do I do?
package com.example.app.views import android.app.DatePickerDialog import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.View import android.widget.ArrayAdapter…
-
1
votes1
answer11
viewsReactor - After filter false, call another method
Given the code below: fun method() { return gateway1.getPerson(id) .filter { isPersonValid(it) } .flatMap { gateway2.isPersonHasAddress(id) } // Retorna Mono<Boolean> .filter { it }…
-
1
votes2
answers248
viewsHow to return values of a daughter Activity in Kotlin
Hello, I’m starting to work with Kotlin and I have the following situation: I have the Activity Foo with a button that navigates to Activity Bar. In Bar, I process some information and have a button…
-
1
votes1
answer62
viewsHow to create extension methods in Kotlin
Hello, I’m coming from C# to work with Kotlin and C# when there was any code that was used constantly, it was common to create extension methods that worked as shortcuts to it. Ex: namespace Test {…
-
1
votes1
answer117
viewsHow to get user order data in Firebase database?
I have an Android app in Kotlin that orders pizza delivery where the company receives the data of the user’s order and I want the user to also receive the data of the order he made, some time ago I…
-
1
votes1
answer80
viewsFragment closes by clicking on Textview Kotlin
Save list! Next, I have an Activity where I call a Fragment using // ... val manager = supportFragmentManager val transaction = manager.beginTransaction() _Fragment = AcvtFragmentView() val args =…
-
1
votes0
answers120
viewsReading csv file with Kotlin
I am beginner in Kotlin and have the following class to read a csv file: @Service class ClienteImportService { fun obtemTodosMsisdn(args: Array<File>) { val reader =…
-
1
votes1
answer174
viewsChange font Textview
I am having problems changing the source of Textview in my project, I have tried all methods found on the internet and none altered. No debug errors and no errors when opening the app. I’m using the…
-
1
votes0
answers38
viewsHow to show nested part of a json in Kotlin
My class date data class News ( val title: String, val pubDate : String, val link : String, val description : String, val content : String, val categoria : String, val linkImg : String ) My Adapter…
-
1
votes1
answer79
viewsToast setGravity() method does not work in Level 30 API
I’m trying to convey a message from Toast on top of a Activity common, when clicking on a Button, using the method setGravity(Gravity.TOP, 0, 0) in API Level 30 (release R), however not working. The…
-
1
votes0
answers55
viewsCreation of tables Sqlite(Room) on Android with the standard Repository (very simple question.. but I need a clarification)
Guys I have a question in the creation of tables and another in the issue of Repository, so come on. EX: data class Carro( val marca: Marca, val motor: Motor ) data class Marca( val nome: String )…