Posts Tagged ‘Class’

Android: Fixing the API 12 Demos project errors

Click here to read Android: Fixing the API 12 Demos project errors

This post shows how to fix some of the most common errors when creating a project with the API 12 (Android 3.1) demos in the Eclipse IDE. The API samples comes bundled with the Android SDK and are a set of Activities that exemplifies how to do almost anything in Android. Following the instructions described at the official documentation to create a new Eclipse project with the API demos 12 code will cause a lot of errors.


Unity: Rotation Controller

Click here to read Unity: Rotation Controller

Another day, another Unity3D programming post. This tutorial contains not just one, but two scripts that rotates a game object around another one, based on the keyboard input. Again, like the previous tutorial, this was also inspired by retro games, such as S.T.U.N. Runner or the special stages from Sonic 2, where the player controls the main character by pressing left or right, making it complete a full circle in the screen. However, unlike those games, the below scripts aren’t applying gravity to the player, for the sake of simplicity. Everything explained here is available for download at the end of the tutorial.


Android: changing the ringer volume

Click here to read Android: changing the ringer volume

Another Android tutorial, this time, explaining how to change the different sound volumes of the Android system, such as the ringer, music and notification loudness. The source code featured below is available for download at the end of the post.

Using a seek bar to control audio’s volume in Android is a lot like changing the screen brightness with a seek bar. However, instead of using a ContentResolver to obtain the service that controls the audio, Android has a class that makes everything easier, named AudioManager. So, the example here will basically obtain a reference to the AudioManager and will use it to get the current ringer volume and use it to set the progress of a seek bar. When changed, the seek bar progress will set the value of the sound volume. Here is the code: (more…)

Android: Loading files from the Assets and Raw folders

Click here to read Android: Loading files from the Assets and Raw folders

This tutorial will explain how to load files from the res/raw and the Assets folder using a String to specify the file name. Yes, there are a lot of tutorials on this subject, but they all use the automatically generated integer IDs from the R class as inputs and not many of them even mention the possibility of loading files from the Assets folder. As a result of depending on the ID, the file reference must be known beforehand.

Instead, the code featured in this post will explain how to find the reference to the file and then load it at runtime based solely on its name. This means that the reference ID and the file don’t even have to exist in the first place, and can be acquired at run time.


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…)