Author: Francesco Rigoni

8 code snippets for Android developers

This is for all the lazy people. I listed 8 common tasks that Android developers usually face, it's the kind of stuff that interrupts your train of tought and makes you think "Oh God.. this is boring and I have other things to do, let's google for some code". And here it is. In no … Continue reading 8 code snippets for Android developers

Using BitmapShader in Android

Recently I had to implement some custom UI controls for one of our customers, and some of these controls involved drawing Bitmaps with rounded corners. Android provides a handy approach to this problem, all the magic can be done with a little help from a class named BitmapShader. With BitmapShader you can draw bitmaps in … Continue reading Using BitmapShader in Android

Codility and the “K complementary pairs in array” challenge

Recently I had to confront myself with Codility, for those who don't know it Codility is an online tool that provides coding challenges and it is often used by companies in the process of hiring new people when they want to test people's coding skills. But that's not all, Codility also provides a great training … Continue reading Codility and the “K complementary pairs in array” challenge

How to know if your Android App is in background

The Android framework does not provide an easy way to detect if an App has gone into background. While it's really easy to know if an activity is visible or not with it's onStart() / onStop() methods, this does not really tell us much about our application state. Think this, you may want to be … Continue reading How to know if your Android App is in background

How to get the SHA1 hash sum of a String in Android

Here's one piece of code that comes very handy in some situations, just copy and paste this to get the SHA1 hash sum from a text String. The Hash is returned as an hex encoded human readable String, see below for an example of use: Here's how to use this, just an example: The code … Continue reading How to get the SHA1 hash sum of a String in Android

Android Snippet. How to quickly run code on the main thread

Here's a simple code snippet that enables you to run a Runnable object on the main thread, or UI thread. This is very handy if you have to update your UI from a background thread or an AsyncTask. It does not require something in particular, this code can be run from everywhere inside your application: … Continue reading Android Snippet. How to quickly run code on the main thread