android

Sync two ScrollLayouts when scroll

Sync two ScrollLayouts when scroll

If we need to scroll two ScrollLayout at the same time we can create a new View th...

Add shadow to labels, buttons and other views

Add shadow to labels, buttons and other views

We can drop shadows to our controls (TextView, Buttons, Checkbox, …). Adding this ...

Create nice buttons with XML

Create nice buttons with XML

We can create nice buttons simply using few colors and gradients. We need to creat...

Cleaning unused Android resources

Cleaning unused Android resources

On middle/big projects we usually add lots of resources that we can use on code fi...

Check missing strings for a multi-language Android application

Check missing strings for a multi-language Android application

When we are creating a multi-language application for Android, we need to create s...

Launch Activity from a service

Launch Activity from a service

If we have a service in background and we need to launch an Activity in foreground...

Optimize lists a 175%

Optimize lists a 175%

two operations are expensive when we create custom lists: Inflate (covered on the ...

Optimize lists a 150%

Optimize lists a 150%

We can optimize the Adapters attached to a ListView inflating our custom layouts w...

Play alarm sound

Play alarm sound

We can play the user’s alarm sound in our application using the class RingtoneMana...

SSH, execute remote commands with Android

SSH, execute remote commands with Android

We need to download the JSCH libraries and JZLIB libraries that we can get directl...

Broadcast intents

Broadcast intents

We can send broadcast messages - Intents - in our application. They can be useful ...

Database not open

Database not open

A very common error when we are working with database is not check that we have th...

Resize layout on show/hide keyboard

Resize layout on show/hide keyboard

Sometimes we need to resize the layout when the keyboard appears. For example, whe...

Intercepting back button

Intercepting back button

In order to intercept the BACK button and other buttons (without include HOME butt...

Use custom fonts

Use custom fonts

In order to use custom fonts in some Views, we need to import the font files to th...

Drawable to Bitmap (and vice versa)

Drawable to Bitmap (and vice versa)

This code convert a Bitmap to Drawable and vice versa. It is useful when we are wo...

Multi-language application

Multi-language application

If we need to create an application that supports different languages, we need to ...

Gradient backgrounds

Gradient backgrounds

We can create easily backgrounds with XML drawables. In this example, we will crea...

Saving and loading preferences

Saving and loading preferences

Save and load preferences on Android is quite easy. You can save primitive values ...

Update user interface from a thread

Update user interface from a thread

With the class Handler, you can throw a Runnable class (a intended to be executed ...

Left and right swipe (gesture events)

Left and right swipe (gesture events)

Android has some tools to receive touch events, but with this code, we will receiv...

Getting the device wallpaper

Getting the device wallpaper

We can get the background that is currently used by the device and convert it to a...

Getting application version and other package information

Getting application version and other package information

This code gets the version that you used in your ManifestFile.xml and save it in a...

Full screen activity/application

Full screen activity/application

Set your android application on fullscreen view, removing the default Android task...

On text change in EditText view

On text change in EditText view

Create a listener when an EditText changes the text inside. I have added a button ...

Send and receive information from Activities

Send and receive information from Activities

This is an easy example about how to pass information from one Activity to another...

Yes/No dialog

Yes/No dialog

This code shows a yes/no dialog as pop-up. The code can handle the response. // Y...

Creating a horizontal line

Creating a horizontal line

This code inserted in the a layout can be used to show an horizontal line. <!-...

Inflating view

Inflating view

You can reuse a View from a XML file in your code loading it like a View. It is us...

Intercepting URL from default browser

Intercepting URL from default browser

This code intercepts an URL opened from the default Internet browser in Android an...