Archive for the 'Android' Category

Data SMS – An Annoying Android Fragmentation Bug on the Samsung Galaxy

Friday, September 25th, 2009

A code contained in a Data SMS is required to authenticate the MSISDN of the device running my product.

When I receive a data SMS on the Samsung Galaxy, the Intent “android.intent.action.DATA_SMS_RECEIVED” is not thrown and the Data SMS arrives in the Inbox as a blank text message.  Any data contained in the Data SMS seems to be lost once it arrives in the Inbox.

Here is a little app I wrote which detects the MSISDN (not working on many devices) or lets you enter it, then send either a Data SMS or a Text Message.  The app will then display any incoming Data or Text SMSs by the intent they throw and allow you to interrogate the native Inbox to determine what data was saved.

Time to file a bug!

Bug Report
Forum

Android Cupcake Device Review > HTC Dream

Saturday, September 12th, 2009

HTC Dream

The original Android phone, which came shipped with Android version 1.0 but promptly performed a seamless self update to Cupcake after I took it out of the box and connected it to the internet for the first time.

This device is only interesting for testing (post Cupcake) because it has a hardware keyboard which by default will restart the running Activity every time you flip it out.  This uses a slightly different event notification system to the rotate listener, which is the only way of changing screen orientation on the other 3 Cupcake devices.  The hardware keyboard makes it currently the best available Android phone for writing messages, but the retarded amount of on board memory means you must start deleting stuff after downloading your tenth application.

A lot of developers have a “Android Developer Phone 1” device (now out of stock) which is essentially a pre-rooted HTC Dream, giving developers full Linux level access so they can install their own firmware.

Please note, that a rooted phone is not required if you are only intending to develop Application level software, as any Android device will run a self signed application as long as you check “Unknown Sources” in Menu > Settings > Application settings.

There is no 3.5 audio jack on this device, instead use the ExtUSB connector with the headset provided.  Some editions of this device come with a 3.5 headset and ExtUSB adapter, allowing users to use their own headphones to listen to music.

Device specific test cases:

  • Flip out that keyboard a couple of times on each screen.  Badly written applications will lose UI state (form data, selected tabs, etc), or freeze if they are in the middle of a long running process started from within the Activity (consider using a service in this case).
  • Try and perform all actions using the keyboard (as if the touch screen were broken).
  • Test for trackball slide clicks (i.e. when the user mistakenly presses the trackball when they intended to slide it).  The proper way of handling this is to ignore all trackball clicks that occur less than half a second after a trackball drag.  This test is useful for games that implement trackball events themselves, as we are used to the native Android UI handling this on our behalf.
  • Flash your Developer Phone firmware and test your Application on an early build of Donut.

Android Cupcake Hardware Review

Saturday, August 22nd, 2009

This is a review of all the mobile phones currently being sold (outside of China) that run Android Cupcake.  I am an Android Third party Application developer (i.e. not a Google employee or handset manufacturer) and will be reviewing various technical differences that affect developers like myself.

together

With the late arrival of the Samsung Galaxy, I now finally have the full set to play with.

Group

The Samsung Galaxy comes in a bigger box because it comes with a “PC Studio” and drivers CD.  You shouldn’t need a CD to develop on an Android device, because the ADB and USB drivers are included with the Android SDK (more on this in the Galaxy review).

Comparison table:

HTC Dream (i.e. G1) HTC Magic HTC Hero (+Sense UI) Samsung Galaxy
Internal storage 71MB 291MB 155MB 912MB
Camera 3.2MP 3.2MP 5MP 5MP + LED Flash
Battery 1150mAh 1340mAh 1350mAh 1500mAh
Connector ExtUSB ExtUSB 3.5 Audio + ExtUSB 3.5 Audio + MicroUSB
Keyboard Flip out None None None
Controller Trackball Trackball Trackball D-Pad
OpenGL Hardware Hardware Hardware Software
SD Card 2GB 8GB 2GB Not included
Upgrade OTA OTA Via PC Via PC
Screen 30.0cm2 30.0cm2 30.6cm2 30.7cm2 AMOLED
Edit 254px 254px 229px 212px

Additional information, including unrelased devices is avalaible here (documented by Eric Wong).

Comparison notes:
All devices have roughly a 3.2” HVGA (480×320 pixcel) capacitance touch display, support 3G, WiFi, GPS, Bluetooth, accelerometer, digital compass and Micro-SD memory cards.   Only the HTC Dream and HTC Magic are Google experience phones which support automatic updates, the others instead come bundled with software customisations (both good and bad) developed independently by their respective manufactures.

Internal storage
Currently applications cannot be run off the SD Card (unless you have root access), and I don’t expect this situation to change any time soon.  That means the internal phone storage represents the upper limit on how many applications (including contacts/mail/calendar storage & Web Browser cache) that you can install on your phone.

The Samsung Galaxy’s ~6.7GB internal SD card isn’t included here, because you can’t install Applications onto it.

If you have less than 10MB of space remaining, you will get a low space notification and all synchronisation tasks will stop.  To find out this value for your device, look in the device settings:
Menu > Settings > SD Card & phone storage
Look for “Available space” under the “Internal phone storage” header.

All these values are for a fresh device (i.e. reset to the factory settings) and are running a similar retail Cupcake build.  Your results may vary.

Camera
More Mega-pixels usually denotes a better result, but having a flash is important when taking pictures indoors.

Battery
Bigger the better really.  Android background processes can eat up a lot of juice, but us software developers are working on improving this situation.  Actual battery life was not tested.

Connector
MicroUSB is the new standard (according to the EU), so get ready to replace all your chargers and connection cables once again.  All the HTC devices use the ExtUSB which is a proprietary connector is apparently under some debate.  Also, don’t confuse this with the older Mini USB which you probably already have chargers for, as these will also have to go into the bin.

Keyboard
Cupcake comes with a usable on screen software keyboard, which makes it possible to type one handed with your thumb.  This works quite well as long as you remember that you only type a character when you *remove* your finger from the screen.  This makes accurate typing a click, and then drag affair.

The HTC Dream comes with a flip out keyboard (for use in landscape mode), with a good key layout design but effectively requires two hands to use (i.e. typing with your thumbs).  This is much better for data entry, as you get some good tactile feedback from the keys, and the lack of soft keyboard leaves you with more screen real estate for your application.

Controller
For all practical usages, the click ball and the D-pad are identical.  I am yet to test if this makes any difference to Android game play.

OpenGL
All  the HTC devices come with OpenGL hardware “acceleration”, i.e. calculations are performed on a separate GPU chip.  The same code is implemented in software on the Galaxy, meaning that animations run proportionally slower (compared to processor speed) on this device than you would expect, and there is more animation judder when the processor is asked to perform other tasks.

While this isn’t a big issue today, I expect to see greater use if OpenGL in Games and user interfaces  in the coming year.  A good example  of what to expect would be the Rachael UI prototype from Sony Ericsson.

SD Card
Its nice when the device comes with a decent SD card, although only some applications will make use of this space.

Upgrade
Android is quite new, so new revisions and security fixes are coming out all the time and you want to make sure you are using the latest build.  Google experience devices will upgrade themselves, but it’s a bit unclear at this point how (and how often) non-Google experience devices will be upgraded.

The HTC Hero and Samsung Galaxy currently require PC software to download and install their latest updates.  I expect that most users wont bother (or know how) to upgrade, so Application developers should expect to support Cupcake devices for many years to come.  I will call these devices “Dead Ducks” until someone comes up with a seamless way of bringing everybody over to Donut, then Éclair, etc.

This is one area where owning a Google experience “in the cloud” Android device is advantageous, and I wouldn’t recommend any of the other devices until this issue has been resolved.

Screen
Physical screen display area of the device, measured with a ruler.

Edit
The virtual keyboard is essential, but uses up a lot of on screen real estate that your application must take into consideration.  Surprisingly this size varies considerably between firmware customisations, with the Samsung Galaxy using the greatest space with its oversized keyboard.  HTC Dream users have the option of flipping out their physical keyboards, nullifying this limitation.

I have measured the amount of usable on screen pixels available when the virtual keyboard is shown in portrait mode. This is the distance between the top of the virtual keyboard and the bottom of the on screen notification bar.  Fewer pixels means there is a larger virtual keyboard, but conversely, there is less area for your application to display data in.

Individual device reviews to come…

G1 Google Account sign in without T-Mobile SIM

Friday, July 17th, 2009

So you have a T-Mobile G1 running the Android 1.1 firmware, but you don’t have a T-Mobile SIM.  This means you can’t get past the Google Account sign in screen because you don’t have internet access.

Unfortunately you can’t yet access the phone settings to activate WiFi, so the only way to progress is to manually enter an “Access Point Name” configuration for your third party SIM.

Menu > APN Settings
Menu > New APN

Enter the APN settings for your current network.  This is easy if you happen to have another phone lying about, so you can boot it using your third party SIM and scribble down the settings of a relevant APN.

When ADB won’t detect your Android phone…

Tuesday, June 16th, 2009

The official instructions for using your Android phone for development are here:
http://developer.android.com/guide/developing/device.html

So you plugged your Android phone into your Windows machine having forgotten to switch on USB debugging…
Menu > Settings > Applications > Development > USB debugging

Then Windows detected your device as a USB-Mass storage device and won’t change the settings, regardless of how many times you uninstalled the device. Thread on it here.

This solution worked for me and didn’t require editing the registry settings (I don’t know if the reboot is unnecessary).

(1) Plugin phone
(2) Uninstall any drivers that mention “HTC Android Mobile USB Device”
(3) Unplug phone and restart
(4) Install and run USBDeview
http://www.nirsoft.net/utils/usb_devices_view.html
(5) Using USBDeview find the Android device (for some reason Windows hides uninstalled drivers instead of deleting them), right click on it and uninstall.
(6) Follow the official instructions to the letter this time.
http://developer.android.com/guide/developing/device.html

Happy developing.

Dear Mr Tax Man (Re: Android Market)

Tuesday, May 12th, 2009

Taxman

…I here by declare that I have not developed, sold or distributed applications or services over the Android Market and Google checkout payment system.  Please do not begin an investigation into my activities, as I am mealy a hard working bunny who only manages to file his German tax explanation forms on a semi-annual basis.  Please do not crush my dreams under weight of bureaucracy and threat of criminal prosecution.
Mark

[RANT]
It turns out that selling applications over the Android market seems to be a sure fire way of getting myself investigated by the tax man (all of them, not just the German one apparently).

Developers are required to set the sales-tax rate for the local where the customer is buying.  That means customising the correct rate for every state in the US (and individual city’s apparently), European country, province of Zanzibar, etc.  I do not happen to know the tax rate in California, and I expect that nobody would inform me if it were to change the day after I entered it manually into the Market web page.  Developers are not international tax experts, and Google have abdicated their responsibility by charging a blanket ~30% “carrier tax” without taking responsibility for Tax processing itself.

I can hear the sound of iPhone developers (who have this taken care of for them) laughing at us right now.
[/RANT]

P.S. Here’s an idea, how about Google do a *Tax* session at their Google I/O conference?

Some relevant links:
[Question: Legally, is the developer selling the app or is Android Market selling it to end user?]
[Campaign: Android Developers International & Tax Consultation]
[Question: Do I need company to sell applications?]
[MARKET QUESTION: Selling applications on the Google Market]
[MARKET QUESTION: Selling applications on the Google Market]

The busy programmer’s coder’s guide to Android Application Development Essentials

Tuesday, March 17th, 2009

Android books
I realised today that I am probably the only Android developer NOT to have a book out at the moment.

Android Bug/Architectural Issue: How do I handle multiple versions of my own Content Provider?

Thursday, January 8th, 2009

I am writing a component that makes certain functionality available to any application running on an Android device (e.g. an advertising service, stock ticker cache, Snowball server, etc).

cp1.gif
This functionality is useful for application developers, but not interesting to actual users i.e. my component should be included as part of a new application, but not require the end user to explicitly install the additional component themselves.

cp2.gif
I expect that over time multiple applications installed on the phone will want to communicate with my component.  As each new application will have a different certificate, I want to communicate between applications using an Android Content Provider.  To save resources on the device (networking, caching, etc) only one instance of my component should be appointed to handle all queries.

cp3.gif
This works well as Android only registers the first Content Provider for a given URI and then ignores the rest (throwing an “WARN/PackageManager: Skipping provider name xxxx name already used” error each time a new one is installed).

cp4.gif
However if the registered Content Provider is uninstalled, it will immediately break all the other applications that rely on it, even though other instances of the component still exist.

Questions:

  • Does anyone have any suggestions on how to better handle this situation?
  • If I could reregister Content Providers I could handle situations like this, and upgrade components when newer versions are installed.  Perhaps the Android OS could also handle this situation better, by tracking Content Provider naming collisions?
  • Should I be looking at other communication methods to solve this issue?

Note: This has been posted on the following discussion boards:

  • Android Developers (click)
  • Android-platform (click)

Edit 20090108
Just to clarify, the attribute “android:multiprocess” in the “provider” tag seems to have a behaviour that is not relevant to this problem, i.e. it prevents multiple instances of the same Content Provider from existing, rather than affecting multiple Content Providers trying to use the same namespace.

Edit 20090109
Thanks everyone for the replies.  Just to clarify: I am writing an advertising server component at the moment, but other projects that I have in the pipeline essentially have the same requirement.

>>Dianne Hackborn - As far as naming issues, this is why you should use an authority in a namespace/domain you own, so that there will not be naming collisions.<<
My application sits in its own namespace.  I am only having conflicts with different copies of the same Content Provider Component being installed with different applications.

>>Dianne Hackborn - …any client app that is relying on a component that is not part of the base platform needs to deal with the error cases if that component does not exist.<<
If the component is not there, then the application would show an error on start and normally refuse to run.  Result: Bad user experience.

>>Peli - Hm, I think you end up with unnecessary code duplication if you include your component / content provider in every application.<<
This isn’t an issue, as my component is delivered as a small Java class included with the main application.  When activated, the component inflates in size as it downloads content over the internet.  My goal is to manage this process by having only one component activated regardless of how many applications are installed on the device.

>>Peli - I think it would be better if every application that wants to use your component shows a small dialog “You need to install the following component…” with a button that brings you to the download page of the Market for your component…<<
Catching a missing component is easy enough.  It’s just that what you describe adds up to a bad user experience:

  • No user will download a 3rd party advertising server (or any non-core functionality) just to run a game.
  • Installation is already a convoluted process and should only take place once.  Additional APK installations require more downloading, application permission settings, button pressing, confusion, etc.
  • No client of mine will accept a solution that asks the user to jump through any additional hoops (e.g. even the Android Developer Challenge only permitted a single executable).

>>Peli - At OpenIntents we try to resolve dependencies as late as possible - i.e. not at installation time, but the first time the user actually wants to use a particular feature (they may never use it in which case there is no need to install it).<<
This doesn’t work for me as ad funded Applications generally require my component to be available on startup.

>>Peli - I think in the long run Market should have better tools for resolving compulsory dependencies automatically, but for the moment I think this is a good compromise for developers and end users.<<
I agree that this needs to be improved, as there is currently no support for components (downloading, versioning, upgrading, etc) in Android or on the Android Market.  Hence I am trying to get around this issue by “managing” a Content Provider.

>>Dianne Hackborn - Oh wait if what is being talked about is having the same content provider in multiple applications, that is completely the wrong approach.  For a given authority there must be one and only one content provider implementation, living in a single specific .apk.<<
This is how it’s done at the moment, i.e. Android will log a warning (and do nothing) every time an application tries to register a Content Provider URI that’s already in use.  This means that subsequent applications will be broken (and need to be reinstalled) if the original Content Provider is ever uninstalled.  I don’t seem to be able to reregister a missing Content Provider URI at runtime.

>>Muthu Ramadoss - AFAIK, a Content Provider is tied up to a unique Authority.  If you want to support multiple URI’s you do so accordingly by providing different URI paths using the same authority.<<
I explored this approach initially, but it still has the following problem:

Over time, I release a number of versions of my component that other developers subsequently integrate into their own applications.  My component uses the following URI conventions:
content://mynamespace.mycomponentnamespace.version1/
content://mynamespace.mycomponentnamespace.version2/
content://mynamespace.mycomponentnamespace.version3/

Android allows me to search and interrogate each URI to check the status of each Content Provider (allowing me to version my component).  This is fine until v3 of my component becomes really popular and a user installs five games on their phone, each with the same component trying to register the same URI.

The user then gets bored of the first game and uninstalls it, thereby breaking all the other games that rely on the Content Provider that it contains.  As URIs are set at install time, none of the other games will work until the user reinstalls an existing game or downloads a new one - This is a terrible user experience.

Edit 20090109 (#2)
>>Peli - Indeed, for an advertising server, it makes more sense to include that in every application separately, for the reasons you mentioned. I could suggest the following…and all applications can access that one content provider. Would this sound like a suitable solution?<<
I didn’t think of just doing the synchronisation using intents (as they support a one-to-many relationship between components).  I’ll do a proof of concept on Monday to see if this works.  It’ll be a bit of a hassle for the guy who has to incorporate this into their application, but it will do until Android is improved to support components. ;-)

Thank you kindly!!

>>Mark Murphy - Since the content in question is going on /sdcard (right? right?!?), solve the problem by managing the space, not managing the components. Since you already require each application to have your own code anyway, just use a regular Java class to access the /sdcard data store and dump the ContentProvider interface.<<
>>Peli - Ad images and banners should be placed on the SD card, but private data for accounting (number of times an ad had been shown, click- through-rate, last ad shown, etc.) could be stored in a content provider, and it makes sense to share this content provider among several applications installed (e.g. so that the end user is not presented the same ad in every application they launch).<<
While Mark Murphy’s solution could be made to work, communicating outside of the OS would be quite ugly in terms of the security and the hardware assumptions which would need to be made.  I also expect the security regime and file permissions to morph somewhat over the next couple of Android releases, potentially breaking my OS bypass hack.  I’ll put this idea down as a plan B, thanks anyway!!

I think I have enough ideas to get this to work now, and will post my results to the thread and blog early next week.

Edit 20090115 - Solution
The simplest solution (not using intents) is to instruct each user of my component to define a new content provider:

content://myComponentNamespace.theirApplicaitonNamespace

Android lets me search through all available content providers, which can be string matched to my own component namespace.

context.getPackageManager().queryContentProviders(null, 0, 0);

If I find more than one valid Content Provider I can then pass around Synchronisation information (validity, compatibility, version, status, etc) using any of the ContentProvider class methods (I used getType()).

The only problem with this approach is that the application developer who imports my component (as a JAR) will have to define their own custom Content Provider.  This is done by extending the MyComponentContentProvider class (from my JAR) and defining a CONTENT_URI variable.

package test;
import com.whitemice.MyComponentContentProvider;
public class TheirContentProvider extends MyComponentContentProvider {
public static final Uri CONTENT_URI =
Uri.parse( "content:// myComponentNamespace.theirApplicaitonNamespace“);
}

As well as adding the custom provider to the Android manifest.

--provider
android:name="test.TheirContentProvider"
android:authorities=" myComponentNamespace.theirApplicaitonNamespace"

As this is a work time project, I will have to check if I can release the synchronisation code as a working example.

Edit 20090116
>>Peli  - Probably you should not mis-use getType()…<<
I originally choose getType() for simplicity (URI in -> String out), but I will now use query() instead.  However, as my application is not compatible with any other software (i.e. my data exchange has no MIME type), I would be interested if anyone could provide a concrete example of where an inappropriate getType() response might cause problems.

Also, for simplicity I am not using intents.

>>Dianne Hackborn - …Along those same lines, looking for your own special text in the authority to identify content providers you are going to work with is also kind-of screwy.  Typically how we do this is attach meta-data to the component that whoever is interested in identifying specifically tagged components looks for.  Look at the way input method service components are discovered in Cupcake as an example. <<

Here is a small component discovery rewrite, now using meta-data to mark valid Content Providers:

####AndroidManifest.xml####

–provider–
android:name=”test.TheirContentProvider”
android:authorities=”myComponentNamespace.theirApplicaitonNamespace”

–meta-data android:name=”type” android:value=”myComponentNamespace”–
–/provider–

####Java Code####

List–ProviderInfo– pis = androidContext.getPackageManager().queryContentProviders(null, 0, PackageManager.GET_META_DATA);


for(ProviderInfo pi:pis) {
Bundle md = pi.metaData;
if (md != null &&
md.getString(”type”) != null &&
md.getString(”type”).equals(”myComponentNamespace”)) {

    //Congratulations you have now found a valid Content Provider
//Note: keep looking as you might find more

    }
}

The upside of this is that the application developer can now deploy my Content Provider using any URI namespace they choose.  However, I will still recommend the previous naming scheme to prevent damaging naming conflicts.

>>Dianne Hackborn - …Also, have you thought about security at all?  What kind of information is stored on the content provider?  Who can access it?<<
As I understand it, any cross application Content Provider on Android needs to implement its own (i.e. roll-your-own) security solution when handling incoming requests.

My current application (an advertising server) treats this as an open/free to use API, with risk scenarios being managed mainly on the server side.

My next application (component for peer-to-peer data sharing) will require a custom Android Permission for sending data.  This is similar to the “android.permission.INTERNET” permission whereby the user still gets a say as to whether the application can send data off the phone.

I am not yet confident enough in the security capabilities of Android and/or my knowledge of them, to implement an application that handles confidential data.

A glimpse at my First Android Phone

Tuesday, September 16th, 2008

Mockup of the Google Android Bot

Mike “I’m-English-I’ve-brought-my-passport-to-prove-it” Jennings gave a lovely and informative presentation on his new Android handset, which he kindly demoed during the keynote speech but subsequently refused to take out of his pocket during the rest of the day.

Mike Jennings demo of an unknown Android phone in London

Apparently Mike only got authorisation to show this phone in the last 2-3 days, with this being the first time the device has officially been shown in Europe (thanks guys).  Apart from the keynote at the beginning of the day, no one was allowed to view the device close up.

A few notes taken from where I was sitting:

  • It’s black (not white only, as some overzealous bloggers had feared)
  • Supports Wi-Fi and 3g (or is that 3G?)
  • The brand and operator logo were taped out, although logo size and phone form factor would be consistent with the HTC/T-mobile/‘Dream’ device we have already seen.  It appears Mike was trying not to steal the wind from next weeks *official* device launch.
  • All Android devices will have GPS (although this will not be compulsory), but no GPS demo was possible as the device couldn’t get a signal under the Wembley conference hall.  Kudos however goes to Google Maps for automatically switching over to cell-id (or is that Wi-Fi) based position information (and visualisation).  It would be interesting to know if this was a feature of Google Maps for Android, or something baked into the platform.  As discussed before, this kind of position approximation will be vital for all those location based social applications we have been promised.
  • Mike demoed an accelerator app called blue dot, similar to the Nokia bouncing ball.
  • Web browsing was in landscape mode, not portrait, although Mike didn’t choose to demo the slide out keyboard for us.
  • Ironically Mike didn’t demo an actual phone call, even when prompted.  His explanation was that he only had a data SIM card in the phone.  To date, I have never seen any Android voice, audio, or text to speech capabilities, which is a situation oddly reminiscent of the old iPhone release joke.

Mike spent the rest of the morning making the most out of his public relations training, as he faced a tough audience hungry for meaty technical details.  Having to field the now obligatory-at-Android-pre-release-conferences “Operators are bastards” question (actual quotation) and taking it in his stride.

Video now on youtube

Google Developer Day London 2008

Tuesday, September 16th, 2008

Google Day London 2008 Keynote
This event turned out to be a lot of fun, despite a registration glitch that sent me a “this event if full, try again next year” email.  A big thanks to Silvia for encouraging me to follow up on that email and get myself re-registered (you’re a star) and to someone at Google call Liz for forwarding all the final event details.

What made the event was the free food, friendly presenters and the chance to make some quality Android contacts.  Highlights being Mike “I’m-not-an-American-I’m-Canadian-with-a-British-passport” Jennings’s Android keynote/device demo/Q&A, meeting some up and coming Android consultants from novoda.com and a rather solid discussion on application traceability with alsutton.com.

A note also goes to Reto Meier who is writing (or frantically updating for 0.9) his book titled: “Professional Android Applications”.  By the sounds of things, the book will definitely be worth a read and made for a good excuse for the speaker to pick on the author while fielding some of the more technical questions.

Unfortunately I only got to *watch* the lightning talks, and not demo Snowball as I had already upgraded my laptop to Android SDK 0.9 and hadn’t had time to bring all my code up to spec.  This was a problem shared by many (to varying degrees), and is a reminder to inventors to always carry around their elevator pitch/product demo on PowerPoint.

According to an unnamed Google employee, constant SDK updating is just one of many Android problems that will be “solved by the launch”.


Geo Visitors Map