Posts Tagged ‘Android’

Posts that contains tutorials and information about Google’s OS, Android.

Android: how to create a loading screen – Part 1

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

This is the first of three Android post in a series that explains how to code a simple loading screen that shows the progress of operation before the application’s View is loaded. This first tutorial objective is to create this loading screen in simplest way possible. The code featured in this tutorial has been developed and tested in Android 2.1, but it should work without much modification in later versions. All code featured in this tutorial is available for download at the end of the post.

Because of the nature of the Android operational system and the Activity stack, there’s no way to precisely determine the loading progress of an Activity. That’s why, in the below example, the Activity is going to be started, but instead of loading the standard View, it will load a ProgressDialog object and simulate a computationally heavy process on a background thread right on the beginning of the onCreate() method.

(more…)

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. (more…)

Android: Initialize View child class object from a XML file

Click here to read Android: Initialize View child class object from a XML file

This tutorial shows how to inherit from the View class to create your own customized View element, and how to initialize an object from this child class with parameters defined at a layout XML file. There are two major advantages in this approach over initializing the extended View object at the Activity.

The first is that the Java part of your code remains clean, without a lot of member variable assignments to set the View’s basic parameters. The second and most important, is the possibility to instantly preview the changes at the Graphical Layout tool in Eclipse without the need to execute the application. This means that the space this customized View element takes on the screen can be immediately be seen and adjusted, if necessary.

(more…)

Android: Bitmap to Integer array

Click here to read Android: Bitmap to Integer array

As stated in the title, this post explains how to generate an Integer pixel array from a Bitmap object, that will hold the color information from each pixel of the image. This post also explains the opposite: creating a Bitmap object from an Integer array. This can be useful when one needs to apply effects to Bitmap instances. As usual, an example Eclipse project is available for download at the end of this post. It works both on the emulator and on physical devices running Android 2.0.

So, let’s get to the code. Putting it in a simplified manner, the below Activity decodes a PNG image into a Bitmap object, then, an array is created with the same number of pixels as the image. After that, a method from the Bitmap instance puts the pixel color information in the array. (more…)

Android: obtaining SD card memory information

Click here to read Android: obtaining SD card memory information

This Android tutorial explains how to obtain the primary external storage (normally, the SD card) information, such as the total available space and how much memory it has left to be consumed by applications and data. Fortunately, this is a short and simple code, that can be used to create file explorer app, or to check if the SD card has enough space to copy data into the external storage. An example Eclipse project with the source code is available for download at the end of the post. It requires Android 2.1 (Eclair) and works both on a real and emulated devices.

In simple terms, the code below checks for a connected SD card, by querying its state. If a external device was found, it then obtains the external memory’s total and available sizes, returning the values in GB, MB, KB and bytes: (more…)