Dependency injection (DI) is a technique widely used in programming and well suited to Android development, where dependencies are provided to a class instead of creating them itself. By following DI principles, you lay the groundwork for good app architecture, greater code reusability, and ease of testing.

The new library defines a standard way to do DI in your application by providing containers for every Android class in your project and managing their lifecycles automatically for you.

Hilt is built on top of the popular DI library Dagger so benefits from the compile-time correctness, runtime performance, scalability, and Android Studio…


View binding is the current recommendation from the Google team for importing the views from XML to Activity, Fragment, or Adapter classes. View binding is a feature that allows us to more easily write code that interacts with views. In most cases, view binding replaces findViewById. It supports both Java and Kotlin.

To learn more about view binding check out the official documentation.

Main advantages

The new ViewBinding feature has some advantages compared to the traditional approach and some of the libraries:

  • Null safety: view binding creates direct references to views, there’s no risk of a NullPointerException due to an invalid view…


Coroutines are a neat new feature of the Kotlin language that allow us to write asynchronous code in a more idiomatic way. — This also means you can write asynchronous code the same way you would normally write synchronous code in your project.

Already, I have explained about MVVM in detail in my another post. Please check that for better understanding of MVVM. in this post, I am focusing on coroutines and retrofit working together.

MVVM With Retrofit and Recyclerview in Kotlin [Example]

The flow diagram for the coroutines with retrofit in viewModel.


WorkManager is one of the Android Architecture Components and part of Android Jetpack, a new and opinionated take on how to build modern Android applications. WorkManager is an Android library that runs deferrable background work when the work’s constraints are satisfied.

Earlier we had AlarmManager, JobScheduler, FirebaseJobDispatcher for scheduling the background tasks. But the issues were

  • JobScheduler — Available only for API >= 21
  • FirebaseJobDispatcher — For backward compatibility

So developer had to understand which method to use when. To overcome these issues we have WorkManager, and it will automatically choose the best method for your task and you do…


MVVM architecture is a Model-View-ViewModel architecture that removes the tight coupling between each component. Most importantly, in this architecture, the children don’t have the direct reference to the parent, they only have the reference by observables.

MVVM stands for Model, View, ViewModel.


A menu displays a list of choices on a temporary surface. They appear when users interact with a button, action, or other control.

Before getting into details. Checkout my other post on material design,

Progress Indicators — Material Components For Android

Sliders — Material Component For Android

Android Chips — Material Component For Android

To work with material design, First we need to add material design dependency.

implementation ‘com.google.android.material:material:1.3.0’

Types of menus

  1. Dropdown menus
  2. Exposed dropdown menus
Types of menus

Dropdown Menus

Dropdown menus display a list of options, triggered by an icon, button, or action. Their placement varies based on the element that opens them.

Based on…


In this post, I am going to explain how to update the live location to the server every some interval. For example, sending live location to the server for every 1 minute.

To fetch live location we are using android service to run in the background to fetch the location continuously within the given time interval. Due to the current restriction on android services, we cannot run service in the background or after closing the app. To run the android app in the background we need to start the service in the foreground.

I am using locationListener to fetch the…


This post for the developer who what to calculate vehicle speed using gps. I am going to explain How to get current speed using GPS in Android Device By Using the Android Location Manager.

Getting current speed can be used in many ways to the users. With the help of GPS we can find the location. By using simple calculation we can get the current moving speed.

By using this example you can calculate device moving speed programmatically.

Please check out my another tutorial to get current latitude and longitude in android.

Follow the Simple steps to get current speed using GPS

  1. Create new Project.
  2. Add permission in AndroidManifest.xml file.


Ktor is a framework to easily build connected applications — web applications, HTTP services, mobile and browser applications. Modern connected applications need to be asynchronous to provide the best experience to users, and Kotlin coroutines provide awesome facilities to do it in an easy and straightforward way.

Ktor is a new framework for building asynchronous servers and clients. It’s 100% Kotlin and runs on Coroutines.

Why Ktor for android?

Ktor uses coroutines for asynchronous programming to keep the code readable and clean. In addition to that, Ktor has many Kotlinx libraries to help developers with tasks like parsing the response.

Using a networking library…


Photo by Roman Kraft on Unsplash

This is the sample program for crop the selected image using intent in startActivityResult in android.

Follow the simple step to crop the selected image.

1. StartActivityResult for pick the photo from the Camera or from file location.

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);mImageCaptureUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(),
“tmp_avatar_” + String.valueOf(System.currentTimeMillis()) + “.jpg”));
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mImageCaptureUri);
try {
intent.putExtra(“return-data”, true);
startActivityForResult(intent, PICK_FROM_CAMERA);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
} else { //pick from file
Intent intent = new Intent();
intent.setType(“image/*”);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, “Complete action using”), PICK_FROM_FILE);

2. After get the photo ,thenStartActivityResult for crop the selected image using,

final ArrayList<CropOption> cropOptions =…

Velmurugan Murugesan

Lead Software Engineer @htcindia | @github contributor | Blog writer @howtodoandroid | Quick Learner

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store