Monday, April 5, 2010

Speaker Phone Update 1.0.1

Speaker Phone 1.0.1 now supports multiple Widgets on the Home Screens. It can be downloaded from:


Saturday, April 3, 2010

Can Money Be Made From Android Apps?

In the near future I'm going to release Speaker Phone on the Android Market and will be making it available for free so I'm not going to profit from that but ultimately I'd like to make my living from writing Android Apps. I decided to search through the Market Place's most popular Applications and I think I only found one paid App in the whole list, MyBackup Pro to give it a plug. Everything else was free. Getting things for free feels nice but does it affect the whole community? Surely its going to put off professional developers if there is little to be made from the community and this may lead to poor quality applications. The Market Place needs a health mix of amateur and professional developers. The professional developers should be producing robust quality applications and giving something for the amateur developers to aspire to as they develop their careers.

Friday, April 2, 2010

Speaker Phone Screenshot

I thought I should post a screenshot so you can see what you are installing if decide to give it a try.

First Android Application

My first Android Application is ready. I have developed an application which automatically enables the Speaker Phone when making or answering a call.

At the heart of the application is a service which monitors the state of the phone. When the phone is off-hook the Speaker is enabled and then disabled when hung up.

Enabling and disabling the service is performed via a Home Screen AppWidget. This part was the most difficult to develop and I'm still not sure I have implemented this correctly. When I have time I will post the AppWidget code here for comments.

When starting the application itself it simply displays details about the application, instructions and a link to here.

In future updates I'd like to make the button into animated images like the HTC Sense Wi-Fi and Bluetooth buttons. I would also like to make it available to be enabled/disabled for other developers to use in their applications.

I have set up a discussion area on Google Groups so please any problems/feedback there and I will attempt to deal with them. The link is given below. Please remember this is my first Android app and its free!

Lost Droids Google Group

I've tested on a HTC Hero (Android 1.5) and used the 1.5 and 2.1 Emulators. I currently have one known issue which occurs if two or more Widget as are applied to the desktop. In this case only one of the Widget is updated, I will address this soon.

It can be download from:


Tuesday, March 2, 2010

Corrupt Android Camera Preview

I have been playing code to use the Camera and came across an issue which I couldn’t find a resolution for. When you run any of the various samples around the Internet they all appear to suffer from the same issue, the Camera preview is corrupt in Portrait mode. I found a fudge which switches the mode to Landscape before showing the Camera Activity but this was less than ideal because you get a short pause as the phone switches display modes. I eventually came up with the solution below in the surfaceChanged method:
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {

if (previewRunning) {

Camera.Parameters p = camera.getParameters();

// Check orientation and set size as w, h or h, w.
Display display = ((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay();

if(display.getOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
p.setPreviewSize(h, w);
} else {
p.setPreviewSize(w, h);

try {
} catch(IOException e) {

previewRunning = true;

The key to this solution is the order of height and width in setPreviewSize, which should be h, w when in Landscape or w,h when in Portrait.

Monday, February 1, 2010

Android Numeric Soft Keyboard

I recently spent some time trying to figure out how get the Soft Keyboard to default to numeric input when I only required numbers entering. It’s actually quite simple but took awhile to figure out. All you have to do is add the ‘android:inputType’ to the EditText resource element. You can then add numberDecimal for numbers with decimal places or number if no decimal places are required.


Android Screenshots

One of the annoying things about Android is trying to get a screenshot from the device. With the current versions of Android there are two options, root your device and download an app or connect your device to a PC with the SDK installed. I will attempt to describe how to do the later on the Windows Platform.

Firstly you need to install the Java JDK from Sun. I am running 64 bit Windows but opted for 32 bit Java as I have run into difficulties in the past using the 64 bit version. Just install Java into the default locations. You then need to add the path of java.exe to the System environment variables. When you look in Programs Files (or Program Files (x86)) you will find that the JDK installed also installed the JRE (Java Runtime Environment), I would recommend adding the JDK location to your path and not the JRE. In my case this is:

C:\Program Files (x86)\Java\jdk1.6.0_17\bin

I also added a new environment variable JAVA_HOME. I’m not sure if this is strictly necessary but since I run a development system I have it set. Setting it if it isn’t necessary will do no harm. If you find you don’t need it please let me know. JAVA_HOME should be set to the JDK directory, in my case:

C:\Program Files (x86)\Java\jdk1.6.0_17

Once Java is configured you need to download the Android SDK and install it. Installing is simply a case of unzipping to a location of choice. You then need to create another new environment variable ANDROID_SWT which points to the path containing swt.jar. The SDK installed two versions of swt.jar, one for 32 bit Java and one for 64 bit. Note this does not depend on the version of Windows but the version of Java, so in my case I set it to:


The next step is to install the USB device driver for Android. To do this you need to use the SDK to download the driver. You need to run ‘SDK Setup.exe’ from the root of the Android SDK directory, in my case:

C:\Programs\android-sdk-windows\SDK Setup.exe

This application will attempt to connect to the internet to download SDK packages and the USB driver. You can select Accept All and then Install Accepted. I would suggest that you follow the driver installations details from the Android Developer site.

Next on your phone you need to enable debugging. On my Android 1.5 HTC Hero, I selected Settings, Applications, Development, USB debugging. Once this is done connect your phone to the PC.

Finally we can have a go at taking a screenshot. To do this you need to run ddms.bat from the tools directory of the SDK, in my case this is:


This will execute the Dalvik Debug Monitor. In this application you should be able to see your device in the upper left hand windows. Select the device and then use the Device Menu to select Screen Capture...