Google Android Development Agency SASS
Showing posts with label google. Show all posts
Showing posts with label google. Show all posts

Tuesday, 24 November 2009

Android Activity States and State Transitions

I wanted to tidy a bit of our Android code up recently to make sure that each Activity was handing it's state properly and to make sure that things were getting cleaned up when the Activity was done.

Before doing this it was important to fully understand the lifecycle of an Android Activity and to understand the state transitions that will and can occur within one.

An Android activity basically exists in one of four states:


Here's a bit more detail about each of these states:

Active
The Activity is in the foreground of the screen and is interacting with the user

Paused
The Activity has temporarily lost focus behind a new non-fullscreen or transparent Activity. In this state is retains all of it's state, however, if Android detects a low-memory situation it may be killed.

Stopped
The Activity is totally obscured behind another Activity. Again it retains it's state, but is much more likely to be killed at any point.

Finished
The Activity has been closed, either by Android or by calling finish(). The state it had dies at this point (unless you explicitly save it).


There are seven events in the Android Activity Lifecycle which give you a bit of control over what happens during each state transition.

onCreate(Bundle icicle)
Fires when the Activity is first launched. You would normally do all of your setup in this method. You can also retrieve any previously saved state from the supplied Bundle.

onStart()
Called when the Activity is becoming visible to the user, for example when another Activity higher in the stack has closed.

onRestart()
Called after the Activity has been stopped and is being restarted.

onResume()
Called when the Activity is becoming interactive to the user.

onPause()
Called when Android is about to start resuming another Activity. You would normally use this to stop anyting dynamic that is happening in your Activity, e.g sounds playing, animations happening.

onStop()
Called when the Activity is no longer visible, usually because another Activity has started over the top of it.

onDestroy()
This is the last breath of your Activity, called just before Android pulls the plug on it.

Here's a state transition diagram to show the sequence of states and the events in between:



Monday, 23 November 2009

Google Chrome OS Beta first install

No posts for a few months, mainly due to the lack of mobile development action over here!

Just downloaded the first build of Google Chrome-OS and installed it on a VMWare virtual machine.

First impressions: Booted up very very quickly. I can definitely see the use for it in low-cost netbooks and for couch surfing. However, there are a couple of things which I can foresee might scupper it: No iTunes/Media playing and no image editing. All very well sticking your photos on Picasa or Flickr, but how are you supposed to get them off your device and edit them without any means of installing desktop editing software, or without provision for storing files locally?

I currently use a Macbook for surfing on the couch and for dragging photos off my cameras and onto Flickr. I would have considered Chrome-OS an alternative for this (farewell Apple at last...) but without just a few more niceties I can't make that switch.

Anyway, here's some screenshots of the login screen and the first screens you'll see.






All those apps you see above are of course just links to websites, although Google have mentioned in their design documents that they are hoping to use popups for sub-tasks, like the one shown below.



If you want to try it yourself, head over to http://discuss.gdgt.com/google/chrome-os/general/download-chrome-os-vmware-image/ and grab the VMWare image. (If you have trouble logging into the virtual machine, try the username "chronos" without a password).

Tuesday, 19 May 2009

New Tub Thumper Version

Today we released a minor update of our Google Android application Tub Thumper.

Tub Thumper is a touch screen drum machine for the Google Android platform and has proved immensely popular since its release last November.

This version is a minor release with a new hip-hop style drum kit, to wet people's apetites for our upcoming major release.

We've been hard at work developing Tub Thumper Pro, which will feature many new cool things. Notable assignable drum pads and the ability to sequence beats, similar to using a Roland TR-909 drum machine.

As it's not yet ready I'm not saying much more, but here's a sneak preview of assigning some drum sounds:



We're aiming this release for the Cupcake build of Android, which will have hit everyone's phones by the time we release it.

At SASS, we spend most of our time working on client projects; developing web and mobile applications for clients. It's nice to get a break from this to work on some of our own projects such as Tub Thumper and it gives us a great opportunity to try out new development ideas and increase our knowledge as developers. There does not seem to be a huge amount of Android developers around Manchester and Cheshire so it often feels like we're out on our own, but we'll continue to experiment and release new Android apps to showcase our ideas.

You can grab Tub Thumper from the Android Market. Just search, or check out the most popular Multimedia apps.

Friday, 24 April 2009

Problems with Android 1.5 pre release

Just been trying the pre-release of Android 1.5 and hit a problem with one of the new features of the emulator.

With this version, you can create "Android Virtual Devices" (AVDs) which allow you to run multiple configurations of the emulator side-by-side without having to run long command line switches.

I'd created my new 1.5 AVD using

android create avd --name cc --target 3 --sdcard 16M --skin HVGA

but then trying to invoke (emulator @cc) it gave the error

could not locate a virtual device named 'cc'

If you run into this problem, you can diagnose what's wrong by running

emulator -debug avd_config -avd cc

Running this gave me a weird path problem, the emulator was trying to find the .ini file for my AVD in c:\Users\Andy\ instead of e:\andy\. (I'm on Vista and my profile is on drive e:\).

To fix this, all I had to do was create a new environment variable ANDROID_SDK_HOME and point this at the moved profile directory. Restarted the command line so that it would register the variable and all was well.

Now for some Cupcake fun!

Thursday, 19 February 2009

Android RC33 for the UK coming soon

Still on RC8 in the UK
Whilst US users of the T-Mobile G1 received the latest update to Android, the so called "RC33" release earlier this month, UK users have been somewhat left in the dark, still stuck on RC8.


RC33 brings a number of cool things to Android, notably voice search and Google Latitude. Note that this isn't the long awaited "Cupcake" branch of Android - it'll be a while (if ever) until we get that on a G1.

According to a comment on this blog post, someone called T-Mobile support and was told to expect the update "sometime around February 20th".

Let's hope they're not lying - I've been developing on Android SDK 1.1 without a hardware device to test it on!

Incidentally - if you want RC33 but don't want to wait, you can follow the instructions here to get it. Don't come crying to me if you brock your phone though... ;-)

Tuesday, 17 February 2009

Second Android Handset unveiled


During this week, the Mobile World Congress has been in progress in Barcelona, and whilst we were expecting to see a whole raft of Android gubbins, it seems that the only big news is the release of the second Android-powered handset, in the form of the HTC Magic.

The Magic will be available exclusively on Vodafone and will be the first handset to feature the Cupcake branch of Android.

This is major news for us here at SASS Digital as Cupcake features signficantly improved Audio-APIs which will help no end in our ongoing development of music applications.

The big question is - will it support multi-touch? I suspect I know the answer...