Tony's ramblings on Open Source Software, Life and Photography
  • warning: include_once() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/oss/modules/highlighter/highlighter.filter.inc on line 26.
  • Highlighter class for language could not be loaded. Code was not highlighted.
  • warning: include_once() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/oss/modules/highlighter/highlighter.filter.inc on line 26.
  • Highlighter class for language could not be loaded. Code was not highlighted.

Finding Google Account on Multiple Android Versions

Cell phone pile @ CCCBIf you want to develop for the most Android devices, chances are you will run across something you need to do differently depending on the age of the device at hand. Newer API's contain different features from old ones.

There's a slick little trick whereby you can handle multiple API versions easily. For instance, finding the Google email address(es) on the phone is a challenge for anything that bridges the "Eclair" threshold. I finally kludged together from multiple sources a working example - nobody handled it quite correctly to do this from any one example I found - although this one came close.

Create an abstract class that manages the details for you like so:

 

Now, you can do something like this from your app:

And don't forget to override the OnActivityResult and read the accounts from the data provided there, if it happens (the old method.)