As we all know that in Android development, the onBackPressed() method has been widely used to handle the back button press event. After introducing the Navigation component in Android Jetpack, this has been deprecated. In this article, we’ll see how…
Search results for: ""
In this article, we will see how to make an HTTP request from an Android application to a server. This is usually done to fetch the data from the API servers. Add permissions As a first step, we should add…
In this article, we will see different ways to return multiple values from a function in Kotlin. Using Pair: As a first way, we can use the Pair to return multiple values from a function. Pair accepts two parameters which…
In this article, we will see how to check permissions from the fragment in Android along with an example. Before we see how to implement the code to check the permissions make sure the permissions are declared in the Manifest.xml…
In this article, we will see different ways to get the current local date and time in Kotlin. Using LocalDateTime Note: Java 8+ is required You can use the java.time.LocalDateTime class to get the current local Date and Time. If…
In this article, we will add the listener to the editText using addTextChangedListener with the lambda functions. Using the addTextChangedListener, we can attach a watcher to the editText view. This function will be called when the text changes in the…
In this example, we will see how to resolve the error “unresolved reference data binding” error in Kotlin. An unresolved reference error indicates that the compiler is unable to locate the classes and resources associated with data binding. Check gradle…
In this article, we will see how to call a suspend function from the normal functions in Kotlin. What are suspend functions? Suspend functions executed within the coroutine contexts are used to write asynchronous programming in Kotlin. These functions allow…
By default, the data classes in Kotlin automatically generate the primary construction which takes the parameter of the declared members. This constructor will initialize all the properties at the time of object creation. The primary constructor does not provide an…
In this article, we will see how to generate a random number in the given range using Kotlin. Using random class from Kotlin standard library By using the kotlin.random.Random class from the Kotlin standard library, we can generate a random…