Posts Tagged ‘Android’

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

Import STL libraries to the Android NDK code

Click here to read Import STL libraries to the Android NDK code

This is a quick tip for those who are beginning to write native Android code. As one may have noticed, it isn’t possible to use containers like, string, vector, list inside the NDK samples. These are all part of the STL (Standard Template Library), and are expected to be available when writing C++ code.

To add STL to your NDK code, locate the Application.mk file inside your project’s jni folder. If it isn’t there, create it. Please note that the Application.mk is not the Android.mk file! The Android.mk file instructs the compiler and the JNI on how NDK code should be handled. The Application.mk, works similarly as the Android manifest file for your NDK code, allowing the programmer to add permissions and define other applications’ properties, like such as ‘enabling’ the STL support.

(more…)

Android: changing the screen brightness

Click here to read Android: changing the screen brightness

This post will explain how to change the current system brightness with a seek bar GUI on Android devices. The code here featured only works on real devices, because it is not possible to see brightness changes on the emulator. Also, all the code explained here is available for download at the end of this post.

The first thing one must know is that Android system brightness value is applied to the screen’s backlight only when the screen turns on. This means that only after a boot up or awaking the phone from a sleeping state will make the screen as bright as the value defined by the System.SCREEN_BRIGHTNESS variable. Consequently, changing only that variable won’t be enough to preview the brightness level.

(more…)

Android: Retrieving the Camera preview as a Pixel Array

Click here to read Android: Retrieving the Camera preview as a Pixel Array

This post explains how to take the live images created by Android’s camera preview feature and return them as a RGB array, that can be used to all sorts of things, like custom effects preview and real-time image filtering. This post used the CameraPreview class that already comes bundled with Android’s SDK because it has everything already set-up, that way is just a matter of inserting more code. The techniques shown here works with Android 2.1 and should work with versions 1.6 and 1.5.

The first thing to do is to import the API Demos project to your Workspace. To do that, in Eclipse, click File -> New -> Android Project. In the dialog that has just opened, give the project a name at the first field (like API Demos 8) and select ‘Create project from existing source’. Now browse to <Android SDK folder>\samples\android-7\ApiDemos. Finally, mark Android 2.1 as the Build Target and click Finish: (more…)

Android: Changing the animation between Activities

Click here to read Android: Changing the animation between Activities

This post features how to change Android’s default animation when switching between Activities. Before reading the rest, please know that the code that changes the standard animation be found at the API Demo that comes with the Android SDK. But since there’s a lack of proper documentation regarding this subject and it’s difficult to find a place explaining it, here is a post that helps in aiding these two problems.

So, the code to change the animation between two Activities is very simple: just call the overridePendingTransition() from the current Activity, after starting a new Intent. This method is available from Android version 2.0 (API level 5), and it takes two parameters, that are used to define the enter and exit animations of your current Activity. Here’s an example: (more…)

Android: Loading and playing videos from different sources

Click here to read Android: Loading and playing videos from different sources

This is the 41st post on the website! It explains how to load images from a variety of locations, such as the ‘Resources’ folder, the SD card and from a remote server. As usual, the source code is available for download at the end of the post.

Let’s start with the basics: video formats. At the time this is being written, Android supports .3gp and .mp4 video files encoded as H.263,H.264 and MPEG-4 SP file formats. For an updated list, visit this link.

(more…)