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 =…

In this tutorial, I am going to explain How to download the image from URL and store the image into sd card directly.

Steps to Download the Image from URL to sd card

Step 1: To download the image we need to have an internet connection. So that First, we need to add Internet Permission in our Application Manifest.xml.

<uses-permission android:name=”android.permission.INTERNET”></uses-permission>
<uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE”></uses-permission>

he permission model/workflow has been changed from API 23 — Android M. So we need to get the permission at runtime.

if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, EXTERNAL_STORAGE_PERMISSION_CONSTANT);
}

Step 2: Get the image URL.

Step 3 : Create Async Task to load the…


This is an Example of Set typeface for webview in android using HTML. In this view set the typeface in HTML String and load with Webview. Put the font in the Assets folder.


Here I have added coding for load image from sd card and set it to the Imageview in android.

Sometimes you need to load the images from the sdcard or from some other location. Here is the example for load an image from sdcard in android.

Steps to load image from sdcard in android

  • Get the exact image path in sdcard.
  • Create Bitmap from the image path.
  • Set the bitmap into imageview.

Step 1 — Get the exact image path in sdcard

By using system intent, browse the android file system and get the exact path of the image. That you want to set in the imageview. In my case, /mnt/sdcard/DCIM/100ANDRO/DSC_0002.jpg


Photo by Glenn Carstens-Peters on Unsplash

This post regarding implementing animation effect for the listview items. By using AnimationUtils, I have implemented this animations for the listview items.

Before start, checkout my other post on listview:

Edittext In Listview Android Example

Steps to create listview item animation

  • Create the listview
  • Create view for the listview item
  • Add animations in anim folder
  • Create the animation and set the animation in the listview adapter

Step 1 — Create the listview

Create the listview and then create simple ArrayList to set in the listview, add values into the ArrayList.

ArrayList<String> items=new  ArrayList<>();
listView=(ListView)findViewById(R.id.listview);
for(int i=0;i<100;i++){
items.add("Item "+i);
}

Step 2 — Create view for the listview item

Create a view to set the items into the listview using the baseAdapter.

Velmurugan Murugesan

Android Dev

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