By default , local unit tests are executed against a modified version of android.jar library. This library does not contain any actual code. So, if we make any call to android classes, it will throw an exception. We can use Mocking Framework mockito to mock objects and define outputs of certain method calls. Mockito is […]
Android
Testing in Android : Part 2 : Using Hamcrest

How to create a simple Unit Test : Open the application we have used in our last tutorial, create one new class “AdditionTest.java” and add the following method : @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } @Testis used to indicate that this method is a unit test method Now […]
Testing in Android : Part 1 : Unit Testing

Why Android Unit Testing is used : Unit testing is used to test each of the smallest testable parts (units) individually and independently . By using unit tests, we can easily verify that logic of the individual units is correct. i.e. we should run unit tests after every build to detect software regressions. For android application […]
- Android
- ...
Retrofit 2 Tutorial

Retrofit is one of the most popular REST client library for android developed by Square . For HTTP requests, retrofit uses OkHttp library. Also we can process the return values easily using custom converters. Following converters are supported by Retrofit : Gson: com.squareup.retrofit2:converter-gson Jackson: com.squareup.retrofit2:converter-jackson Moshi: com.squareup.retrofit2:converter-moshi Protobuf: com.squareup.retrofit2:converter-protobuf Wire: com.squareup.retrofit2:converter-wire Simple XML: com.squareup.retrofit2:converter-simplexml Scalars […]
Android – DayNight View Tutorial

What is day night theme and how to use it on android application ? Support Library 23.2 has introduced a new DayNight theme for Android Apps using which will automatically change the application theme to day or night mode based on the time of day and user’s last known location. Also, this theme can be used […]
Android-Working with Vector Drawable (Part 2)

In our previous tutorial , we have discussed what is a Vector, what is VectorDrawable , difference between svg and Vector and different ways to convert svg images to vectorDrawable.This tutorial will be mainly focused on how to support VectorDrawable on preLollipop android devices. Introduction : Previously , vectors were not supported on pre-lollipop android […]
Android – Working with VectorDrawable (Part 1)

VectorDrawable – what is it ? Introduction : To represent an image in android, we use bitmaps. But the main problem with a bitmap image is that we cannot scale it without losing its quality. That’s why we need to create different bitmap images for different screen devices. With api level 21 ( android 5.0) […]
Android – Material Design Tutorial -9 ( RecyclerView with grid )

In our last tutorial, we have learnt how to implement a recyclerView and different elements of a recyclerview . As discussed, we have three different types of LayoutManger that we can use with a recyclerview.In this tutorial, we will create a simple Application that will create a recyclerview with GridLayoutManager and load pictures to it from […]
Android – Material design tutorial -8 ( RecyclerView basics )

Recyclerview was introduced as a replacement of ListView widget. Like listview, recyclerview is also used to display large set of items inside application. But recyclerview is more advanced and efficient than listview. Introduction : Layout Manager : Layout manager basically defines the types of layout which will be used by recyclerview. Three types of layout managers […]
Android – Material design tutorial -7 ( NavigationView )

In this tutorial, we will discuss about navigation view. Using Navigation View which was introduced with android design support library, we can create a navigation drawer easily that comply with the Navigation Drawer Design Guideline . Create one project in android studio with activity MainActivity.java and layout resource file for this activity as activity_main.xml […]