ing. Andrea Maglie

Access Storage Framework and the URI permissions nightmare

I’ve been working with the Access Storage Framework introduced with Android KitKat, a feature that I’ve been waiting for a long time. Everything seemed to be alright, quite easy to implement, until I faced a strange issue. Once the file has been selected by the user, I wanted to store the file’s URI and re-open that URI the next time applicati... Read more

Don't waste your time coding - part 1

Life is too short: please, don’t waste your time writing code! I’m not saying that you don’t have to code, but many people tend to waste too much time typing on the keyboard instead of producing code. Mee too. Following examples relate to Android’s world, but that can be easily adapted to other languages and programming tasks. Aliases Android... Read more

Auto-increment versionCode in build.gradle file

Starting from this blog post by Bryan Rosenbaum, here is a gradle task to auto increment versionCode inside your build.gradle file. import java.util.regex.Pattern ... task incrementVersionCode << { println(":incrementVersionCode - Incrementing Version Code...") def buildGradleFile = file("build.gradle") def patternVersionCod... Read more

Android Fragment Code Generator

There are many ways to create a fragment in Android, but to create a fragment properly you need to follow specific guidelines. For example, it’s required that the class has a public zero-parameters constructor. If we need to pass parameters to the fragment, we need to use the method setArguments(). Try to pass some parameters to the constructo... Read more

Working with boolean and Parcelables

Here are two simple methods to write a boolean value into a Parcelable object and read a boolean from a Parcelabe. public static void writeBoolean(Parcel destination, boolean value) { if (destination != null) { destination.writeInt(value ? 0 : 1); } } public static boolean readBoolean(Parcel in) { if (in != null) { return in.rea... Read more