Category Archives: ANDROID

Why you should use StringBuilder instead of StringBuffer in Android for better performance?

By | February 25, 2018

StringBuffer StringBuffer is mutable means one can change the value of the object . The object created through StringBuffer is stored in the heap. StringBuffer has the same methods as the StringBuilder , but each method in StringBuffer is synchronized that is StringBuffer is thread safe.Due to this it does not allow two threads to… Read More »

Using Otto Event Bus to Communicate b/w Activity and Fragment.

By | February 15, 2018

Using Otto Event Bus to Communicate b/w Activity and Fragment. Otto Event Bus is an Android Library that helps developers to communicate between Android Activity and Fragment and vice-versa. Lets see a simple implementation of this. Here I will pass a simple string from Activity to Fragment and Vice-versa. Gradle Layout Activity layout Fragment Layout… Read More »

Implementing Downloadable fonts in Android – Kotlin.

By | February 5, 2018

Here is a simple example in which we will download a font from google and set it to our textview. View the Demo here Layout Here is our layout. The Edittext is a autocomplete textview where we will load the font names to download. The font names are stored in values.xml Lets see the layout.… Read More »

How to BackUp user’s data programatically in Android?

By | January 25, 2018

Android’s Backup service allows you to persist the data in a Google cloud storage. Android does this with the help of a BackUpAgent in the SDK. If we want to backup the data, then extend the BackupAgent. Lets see how we can do this. Benefits Reduce user frustration Increase login-rate. Reduce support calls Minimize user… Read More »

Simple Job Scheduler Demo in Android

By | January 20, 2018

Android helps us to schedule jobs in an efficient way. Android has a built in Job scheduler for this. Lets see how this is done. Before that lets see what google has to say about Job Scheduling. These are the normal tasks an application does : Updating network resources. Downloading information. Updating background tasks. Scheduling… Read More »

Store a Class object in Android Preferences or Store Non-Primitive types in Android Shared Preferences

By | December 27, 2017

We all know that Android only allows primitives types like int, float to be stored in preferences. But we can change this with the help of GSON. If you want to know more about GSON, you can refer my post here… Using GSON in Android – Simple Demo Now, In this demo, I will show… Read More »

How to add Deeplinks in your Android Application?

By | November 1, 2017

What are Deep Links? Let’s understand this with the help of a situation. If you happened to click a link on a webpage and suddenly it opens an application inside you phone or opens a dialog asking you to choose an application to handle this click. Yes, this is called deep linking. You can read… Read More »

Useful Android Studio Plugins

By | October 20, 2017

Here are some plugins that are really handy for developers to speed up their development. 1. ADBWIFI This plugin helps you to debug your app over Wi-Fi. Check out my previous blog post on how to do this without any plugin. 2. DTO generator This plugin is useful when you want to generate corresponding POJO… Read More »

How to Create Preferences Settings in your app using Android Built-in Settings Preference APIs

By | October 10, 2017

There is often a settings page when we make our app and most of the people end up making it using their own UI. But interestingly Android provides API specific for building preferences using your own values. Check the below UI for my settings Lets see how that is done. Using Preference Headers Preference Headers… Read More »

Steps to Speed Up/Optimize Android Studio Gradle Build Process.

By | October 1, 2017

Even with good hardware configuration for the system, we often end up with slow gradle build process in Android Studio. So here I will discuss some steps to Speed up Android Gradle build. 1. Stay Up to Date Make sure you have the latest Android Studio and have the latest build tools updated. 2. Create… Read More »

Get Battery Percentage in Android – Different Methods

By | September 25, 2017

We will see the different ways to get the battery percentage in Android. Method 1 Register a Broadcast Receiver Receive like this Method 2 Method 3 Note : Make sure you unregister the receiver when you don’t need.

How to Debug/Run Android application in Android Studio Wirelessly using Wifi.

By | September 20, 2017

Steps Enable usb debugging and Connect the device to dev system with USB cable. Type “adb tcpip 5555” in Terminal/Command prompt. (Here we are opening a port in device to connect from development system.) Disconnect the phone and check the ip address of phone from network settings Type “adb connect :5555” Now the phone will… Read More »

Do we need to call the Garbage Collector manually ( System.gc() ) in Android?

By | September 5, 2017

This is a common question. Eventhough the Android System calls garabage collector at appropriate times, this usually will not be adequate. Because the system calls GC at intervals, most of the time it wont work perfect and causing unnecessary pauses in the application. If these pauses are more than 16ms, then the user will notice… Read More »

How to write Simple Animation while setVisibility.GONE in Android?

By | September 5, 2017

Automatic animations on Layout Change If you want to animate views in a layout without writing big codes. Here is a Simple way. Find the root element of the layout and add this property to it. Adding Manual Animations Fade Out Animation Fade In Animation Move Down by height Translate animate to origin Position Adding… Read More »

How to add finger print authentication in Android.

By | August 30, 2017

Android 6.0 saw the introduction of fingerprint authentication, a new security feature that allows users to confirm their identify with a single touch. Well, after that this has become a common way of authentication for users. Advantages Very easy, fast and convenient to use for authentication Don’t need to remember No struggling with the keyboards… Read More »

How to find location in Android using GPS?

By | July 25, 2017

This example helps you to find the location in Android using the GPS. I have commented out some functionality in the code. You can uncomment it and extend it at your wish. At first we will create a utility class that will handle all GPS related Operations. GPS Utility Class This class has all utility… Read More »

Floating Button like Facebook Chat in Android

By | July 20, 2017

Floating widgets float over the screen over any app that is currently running. Here we will make a floating action button that you can drag around the screen to position and do actions on it. Add Permission For drawing over the other apps, you need “android.permission.SYSTEM_ALERT_WINDOW” permission. So add this entry in your manifest. Our… Read More »

Fast and Efficient way to transfer images between Activites in Android

By | July 14, 2017

We often need to transfer images between activities. Well there are many methods to transfer images. You can make the image into a Base64 String and pass it as String argument extra in a bundle between activities You can save it to a disc and read it in the other activity. Well, these methods will… Read More »

How to send Send form-urlencoded parameters in post request android volley?

By | June 30, 2017

We have to override the getBodyContentType() method in volley to enable “form-urlencoded parameters” in POST request using Volley. Here is how the code will look like. If you are not familiar with Volley, Checkout my post here on volley. It will give you a perfect picture on what Volley can do. Code – Method 1… Read More »

How to enable the default animation on a RecyclerView when an item is added or deleted?

By | June 25, 2017

You may be knowing that RecyclerView is part of the material design, so it will have the built in animations when you add an element or remove and element. In today’s article, I will show you how to how to do this in a simple way. RecyclerView will perform a relevant animation if any of… Read More »

Bottom Navigation Demo in Android

By | June 15, 2017

To get started with this, you need the latest version (version 25) of Android SDK & tools (including SDK tools, build-tools, platform-tools, support repository). Gradle Add the design support library First step is to add the design support library to your app-level build.gradle file. Example is as shown below: Layout Add the BottomNavigationView to your… Read More »