Archive for the ‘Featured’ Category

Android: Creating a two color LED notification

Click here to read Android: Creating a two color LED notification

Another programming tutorial, this time, showing how to make the built-in notification LED on a Android device continuously alternate between two colors. That said, by the time this article is being written, it’s recommended to try this code on a real Android device that has a notification LED instead of running the application on the emulator. Also, the Activity featured below has been created to work on devices with Android 2.0 or later. All code featured in this article is available for download at the end of the post.

To continuously change the colors of the LED, it’s necessary to create and initialize a Notification object that changes the LED colors and post this notification using a handle to the system’s notification service (using a instance of the NotificationManager class). The notification is then canceled, its LED color is changed and the notification is posted again and the process is repeated over and over making the colors swap back and forth. Continue reading: “Android: Creating a two color LED notification”

Android: Creating a WebView dialog

Click here to read Android: Creating a WebView dialog

This Android post shows how to display a WebView inside a Dialog, that renders a website to the user. Since the WebView can load just about any web page, it’s possible to provide any information to users without launching the web browser, so they never have to leave the application.

For this tutorial, all code had been developed and tested in Android 2.1, both on an emulator and on a real device. As usual, an example application with the code featured in this tutorial is available for download at the end of the post.

The first thing required to place a WebView inside a dialog is to create a custom Dialog. After that, a WebView can be added to it. The easiest way to do that is to create a new Android layout file (in Eclipse, just right click the Project folder and select New -> Android XML file). Then, add the following code: Continue reading: “Android: Creating a WebView dialog”

Android: how to create a loading screen – Part 3

Click here to read Android: how to create a loading screen – Part 3

This is the third and final post of a series that explains how to code a loading screen for Android. The other two previous posts (which can be found here and here), used two distinct approaches to solve the problem of executing code on a background thread and update the progress back to the application’s UI thread. However, both of them relied on an instance of the ProgressDialog class to display the current progress. In the following paragraphs, instead of using this type of dialog, a custom View inflated from a layout XML file is going to be created to achieve that purpose.

As the other two previous posts, all the code in this article has been created and tested in Android 2.1. An example Eclipse project is available at the end of the post.

Continue reading: “Android: how to create a loading screen – Part 3”

Android: Use ccache with Android NDK on Cygwin

Click here to read Android: Use ccache with Android NDK on Cygwin

This Android tutorial explains how to set-up ccache to work with the NDK on Cygwin environments. Ccache is a great tool that detects unnecessary code recompilation by comparing the current source compilation with previously cached results, thus reducing the time it takes to complete. The support for ccache has been officially added to the 7th revision of the NDK.

The instructions in this posts have been tested on Windows 7 Ultimate 64 bits and Windows 7 Home Premium 64 bits, using Cygwin 6.1, Eclipse 3.5.2 and obviously, Android NDK r7. The commands to compile Android native code are from this post. Continue reading: “Android: Use ccache with Android NDK on Cygwin”

Unity3D: Using textures larger than 4096×4096

Click here to read Unity3D: Using textures larger than 4096×4096

This post explains how to assign images larger than 4096×4096 px as textures in Unity. This image size is the maximum supported dimension for a texture in that game engine, however Unity allows us to write our own custom shaders that can use four images as textures, instead of just one.

Therefore, this post shows how to create a simple diffuse shader that takes four images to compose a single texture. That way, a 8192×8192 image can be used as a texture by breaking it into four 4096×4096 pieces, thus respecting the engine’s image size limit.

Continue reading: “Unity3D: Using textures larger than 4096×4096”