Image for post
Image for post

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.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission. ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" …

Image for post
Image for post

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 that can be integrated into multiple platforms is a better solution than choosing platform-specific libraries. As JetBrains develop it, there will be more advanced features and long-term support. …

Image for post
Image for post
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) {
} else { //pick from file
Intent intent = new Intent();
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 = new ArrayList<CropOption>();
Intent intent = new Intent(“”);
List<ResolveInfo> list = getPackageManager().queryIntentActivities( intent, 0 );
int size = list.size();
if (size == 0) {
Toast.makeText(this, “Can not find image crop app”, Toast.LENGTH_SHORT).show();
} else {
intent.putExtra(“outputX”, 400);
intent.putExtra(“outputY”, 400);
intent.putExtra(“aspectX”, 1);
intent.putExtra(“aspectY”, 1);
intent.putExtra(“scale”, true);
intent.putExtra(“return-data”, true);
if (size == 1) {
Intent i = new Intent(intent);
ResolveInfo res = list.get(0);
i.setComponent( new ComponentName(res.activityInfo.packageName,;

Image for post
Image for post

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 image from URL in the background. Basically, Android AsyncTask is an abstract class provided by Android which gives us the liberty to perform heavy tasks in the background and keep the UI thread light thus making the application more responsive. …

Image for post
Image for post

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.

Image for post
Image for post

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

Image for post
Image for post
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<>();
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.

LayoutInflater inflater = getLayoutInflater();
view = inflater.inflate(R.layout.list_adapter, parent, false);
TextView itemName=(TextView)view.findViewById(; …

This is very useful when you want to show the error messages for the Edittext field when the user enters wrong information.this is a very simple program only you have to use serError() method in the Edittext.

Step 1

Create button and implement onClickListener.

btnLogin.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub

Step 2

Validate the input fields and set the error in the input field.

Toast.makeText(getApplicationContext(), "Login success", Toast.LENGTH_SHORT).show();
edNumber.setError("Number Mininum length is 4");
edName.setError("Name Mininum length is 4");


Image for post
Image for post

Image for post
Image for post

Progress indicators express an unspecified wait time or display the length of a process. Material design provides an implementation of linear and circular progress indicators, compatible back to API 15 .

Progress Indicators is API-compatible with Android’s progressBar class and can therefore be used as a replacement for the progressBar.

Progress Indicators added in material design in 1.3.0. Now its in alpha 02. So you need to include following dependency to work with progress indicator.

implementation ''

Before starting checkout my other post on material design:

ShapeableImageView — Material Components For Android

Sliders — Material Component For Android

Android Chips — Material Component For…

Image for post
Image for post

Jetpack DataStore is a new and improved data storage solution aimed at replacing SharedPreferences. Built on Kotlin coroutines and Flow, DataStore provides two different implementations:

Data is stored asynchronously, consistently, and transactionally, overcoming most of the drawbacks of SharedPreferences.

If you’re currently using SharedPreferences to store data, consider migrating to DataStore instead.

Also, Checkout my another post on android jetpack:

Room Database Android Example [Beginners]

Android Constraint Layout Tutorial

Type Of DataStore

DataStore provides two different implementations:
Preferences DataStore — stores and accesses data using keys. This implementation does not require a predefined schema, and it does not provide type safety.
Proto DataStore — stores data as instances of a custom data type. …


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