Android Development

I’ve been using the Android SDK for a few months now to develop some silly little applications.  However, just yesterday, after updating to Android 2.2, I discovered the process had become a little hit and miss.  The phone would crash more than usual.  I even lost the SD card and it request I reformat it.  I took it out, rebooted the phone, turned it off again, put the SD card back, rebooted the phone and all seems to be well again.

Well tonight, the Eclipse IDE I’ve been using wouldn’t attach to the phone for debugging any more.  It would download the ‘apk’ to the phone and I could execute it manually but it wouldn’t connect the debugger.   In an attempt to figure out what was going on I updated Eclipse (HELP->Check for Updates), and my Android Plug-ins (SDK & AVD Manager).  This didn’t fix the problem but I now have lots of new Docs and the 2.2 SDK installed.  One problem I did have was that Eclipse locked the folder containing the Android SDK that was being used by my projects.  This meant it couldn’t update it.  So I closed Eclipse and deleted the folder by hand so that Eclipse could update it.  I guess unloaded the projects would have unlocked the folder too.

So why couldn’t I debug?  I discoved the DDMS which I hadn’t seen before.  This is pretty good for looking at the heap in realtime and taking snapshots and viewing the raw file structure of my phone’s OS!  But this only showed that I couldn’t connect to the phone to find any processes.  However, the phone was listed as a device.

Still none the wiser, I started to trundle around my user folders.  I saw the “.android” folder and took a peek inside.  Nothing made much sense so I thought; close Eclipse, delete (or rename) the files in this folder and start Eclipse again.  SUCCESS – Eclipse can now connect to my phone and I can see the processes on DDMS and I can debug my programs again.

I don’t know what happened but the the files I removed were ‘debug.keystore’, ‘ddms.cfg’, ‘androidtool.cfg’, ‘adb_usb.ini’.   The only one which was recreated by running Eclipse again was ‘ddms.cfg’.

Charging an HTC Desire in your car

Car chargers for USB devices are pretty easy to find. I was in Gamestation and picked up a BigBen charger for Sony PSP, Nintendo DS which uses a USB socket on the transformer. Great, I thought, I can just plug a USB->microUSB cable into that and charge my phone.


Mobile phones use a trick to see if the charger actually coming from AC or some other source. This is to protect the device so that that phone won’t try to draw too much current.  Thanks to an old university friend I found the solution.  So all I did was prise open the case, melt a drop of solder between the two data lines (the middle two) and then snap it all together again.  There is a chance that this will draw too much current but it is rated at 1.3A and the phone requires 1.0A, and it appears the logic in the phone itself ensure it monitors how much it is drawing to something around 500mA.

It’ll be fine!

Using my mobile phone as a Bluetooth modem

Having got the bluetooth adator working on my AAO a few days ago, I thought it time to look at getting the modem in the phone working. So I revisited the site that helped me with the bluetooth installation and continued with that. So first:

$ sudo yum install bluez-gnome gnome-ppp

Assuming everything is set up from before and you’ve connected to your mobile phone you should be able to type

$ sudo hcitool scan

to get the MAC address of your mobile. You’ll need this. Next type

$ sudo sdptool records XX:XX:XX:XX:XX:XX

where XX are the numbers of your MAC address. This will give details of how your AAO needs to talk to the mobile phone. You are looking for the DUN (Dial Up Networking) service.

Service Name: Dial-up Networking

and the associated channel number (in my case)

Channel : 1

Now you need to edit the /etc/bluetooth/rfcomm.conf file to read something like this;

# RFCOMM configuration file.

rfcomm0 {
# Automatically bind the device at startup
bind yes;

# Bluetooth address of the device attached to the Acer
device [MAC ADDRESS – eg 00:11:22:33:44:55];

# RFCOMM channel for the connection – use the channel number
# for DUN found with the sdptool records command…
channel [CHANNELNO];

# Description of the connection
comment “My_Bluetooth”;

A reboot is required now so type:

$ sudo reboot

Once you’re back up, get your terminal back up and type

$ sudo gnome-ppp

This will bring up the modem connection dialogue.  The settings I used for Orange (Pay As You Go in my case) were;

Username: user
Password: pass
Remember Password = ticked
Phone Number: *99#

Device: /dev/rfcomm0
Type: Analog Modem
Speed: 115200
Phone line: Tone
Wait for dialtone: unticked

Init strings: (I don’t seem to have an Init1!?)
Init 2: ATQ0 V1 E1 S0=0 &C1 &D2
Init 3: AT+CGDCONT=1,”IP”,”orangeinternet”

I got these details from the Orange support site but another useful site is the GPRS information site.

Connections: I have nothing ticked.

Having entered all this, I closed the setup page and hit Connect. In the terminal window behind gnome-ppp I could see the dialog between the Acer and the phone and…

PPP Connected!!!!

NOTE: It sounds simple enough but I had a shed load of times that the Acer and the Sony Ericsson wouldn’t talk to each other through the “rfcomm0”.  In the end, rebooting with the correct settings in the /etc/bluetooth/rfcomm.conf file and then calling sudo gnome-ppp seemed to do the trick.

%d bloggers like this: