ConstraintLayout in Android

Building a responsive UI in Android has not always been easy considering the number of devices with different screen sizes, aspect ratio, resolution, etc. Complex layouts usually end up containing several nested view groups which significantly decreases performance. The impact of these problems can be diminished by converting your layouts to the flexible and flat in hierarchy ConstraintLayout which I’m going to introduce in this post.

Read more

Persist data effectively with Android Realm database

When it comes to storing application data in a database on Android, there’s not much of a choice the developer has. First of all, there is SQLite as the only officially recommended solution in Android framework. On top of SQLite, there is a number of ORM (Object-relational mapping) frameworks available which aim at allowing developer to work directly with objects when storing and reading data from a database. SQLite is however sometimes not so easy to use and there are some drawbacks due to not being designed specificaly for mobile devices. Luckily, there is another kind of database gaining on popularity lately — the Android Realm database.

Read more

Enable Java 8 features in Android with these libraries

Since Android N, some of the Java 8 language features are finally supported thanks to the new Jack & Jill compiler toolchain. This however comes with several limitations like for example an inability to use the new compiler along with the data binding support library or limited annotations support. But that doesn’t mean that you should give up on advanced language features of Java 8 at all. In this post, I’ll introduce you to a way how to enable Java 8 features in Android by using four libraries back-porting Java 8 functionality to lower Java versions.

Read more

New Date and Time API in Java 8

Handling time and date in Java has always been somewhat complicated. At least until the new Date and Time API was published along with Java 8 release. Before that, developers had to struggle with not so great java.util.Date and java.util.Calendar classes which both had their flaws. In this post, a third in a series introducing new Java 8 language features (see Java 8 Stream API and Lambda expressions tutorial posts), I’m going to present the new Date and Time API in Java 8 and explain why it’s a much better choice than previous date and time APIs.

Read more

AndroidAnnotations for faster development

Writing the same code for each project all over again can be quite tiresome and time-consuming. In this post, I’ll introduce an Android library which could help you get rid of unnecessary boiler-plate code in several common areas of Android app development. The library is called AndroidAnnotations and it will help you develop your applications faster and with less bugs while writing less code at the same time.

Read more

Improve your code with Android Annotations support library

Annotations have been a part of Java programming language since JDK version 1.5. Since then, they have constantly gained on popularity and nowadays you probably couldn’t find a class that doesn’t use at least one annotation in its code. There is also a support library available, providing several useful annotations to be used in Android development. In this post, which is the first post of the Android Annotations series, we’ll have a look at what the annotations from Android Support library have to offer.

Read more

Reduce APK size (2/2): Optimizing code

Optimizing the graphics resources of your android application was the main subject of my previous post. The second post from the “how to reduce APK size” series focuses on optimizing the source code.

In this post, first I’ll describe a few tips for a better optimized code. Then I’ll show you some of the methods of dependency analysis and eventually, I’ll present several tips on how to reduce APK size of your application in case you’re using native libraries.

Read more

Reduce APK size (1/2): Graphics

There are several reasons you, as a developer, should be concerned about the size of your application and be actively trying to reduce APK size as much as possible. For one thing, there are potential users of your application who might be limited by their data plan, connectivity, or storage space on their phones. Offering an application with size of tens or hundreds of megabytes could potentially make them think twice before downloading your app and maybe even go for a different option just to save the bandwidth.

Read more

Android MVVM pattern

In my last post, I’ve introduced the Android data binding support library which helps to get rid of unnecessary boiler-plate code related to view-model binding. In this post, I’d like to introduce you to the Android MVVM pattern (Model-View-ViewModel) which builds upon data binding functionality and helps to keep the architecture design of your applications clean and its parts clearly decoupled.

Read more