OCI Java Lunch: Android

The first 30 minutes of my OCI Java Lunch presentation on Android is on YouTube. We had to split it up into 3 10-minute segments due to YouTube size limits.

The remaining two segments are on the OCItv Channel.

I haven’t watched this myself…I think I was really nervous the first few minutes, but the talk really picked up steam in segments 2 and 3. The second part of the hour isn’t online yet. That’s when I did live demos with my G1, Eclipse, and the SDK. Mario is working on getting that online as well.

Live Mesh Fail

This month’s Wired has an article about Ray Ozzie, where they mention Live Mesh:

Then comes a demonstration of Live Mesh, which will allow people to seamlessly synchronize all their information with as many people and places as they want, across as many devices (computer, phone, camera) as they want.

So I installed it. The installation process kicks Vista into a degraded video mode:

While not a deal breaker, this is annoying and kind of broken. The real FAIL moment comes when you try to use the service with Firefox:

So I tried double-clicking on the “notifier” icon in the Vista task bar, but that just takes me back into Firefox with the same failure message.

Ozzie won’t fix Microsoft with products like this. They still do not “get” the Internet — at all. Nothing Microsoft produces for the web feels like a normal part of the Internet. Live Mesh is already a failure.

Android Lifecycle Triggers, Part 2

Yesterday I showed how lifecycle events fire in response to starting and stopping an Activity. Next, let’s see what happens when you change the display orientation:

That’s what happens without any customization. I marked two methods bold because they are different than yesterday’s diagram. See this comment from Ed Burnette for more details on customizing rotation behavior. Specifically, you can retain data by overriding onRetainNonConfigurationInstance(), or you can prevent activity destruction via the android:configChanges XML attribute.

Phone Call

Android is also useful as a telephone, believe it or not. This next diagram shows what happens when a phone call interrupts an Activity:

See Also…

Android Lifecycle Triggers, Part 1

This is Part 1 of a multi-part series explaining how events, such as clicking the Home button, trigger transitions in the Android Activity lifecycle. You might want to refer back to this Activity Lifecycle Diagram I posted 20 days ago.

This particular comment inspired me:

I like your diagram, the only thing its missing is what causes each transition to happen (i.e. User hits “back” button, user clicks “home” button etc…)

The activity lifecycle is a complicated state machine which cannot live completely in my head so i like having a diagram to reference, however without the transition events its not a complete reference.

This is indeed complex, and one diagram cannot capture all possible transitions. So I’ll split this up into several blog entries. Here is the first diagram I came up with:

To create this diagram, I wrote an Activity that overrides most of the onXXX() methods, writing log messages:

    @Override     protected void onDestroy() {         begin("onDestroy()");         super.onDestroy();         end("onDestroy()");     }     ...     private void begin(String signature) {         // super-hacky code to indent nested method calls         StringBuilder sb = new StringBuilder();         for (int i=0; i<indent; i++) {             sb.append("  ");         }         Log.i(TAG, sb.toString() + "BEGIN: " + signature);         indent++;     }      private void end(String signature) {         indent--;         StringBuilder sb = new StringBuilder();         for (int i=0; i<indent; i++) {             sb.append("  ");         }         Log.i(TAG, sb.toString() + "END: " + signature);     }

I then ran the Activity in Eclipse, viewing the log in the DDMS LogCat window. (NOTE: DDMS is an Eclipse perspective, the LogCat window is in that perspective). I created the diagram using OmniGraffle.

I hope to create additional diagrams showing the sequence of method calls for a variety of events, such as:

  • An incoming phone call
  • The user hits the Menu button
  • Showing a dialog
  • Navigating to a different view
  • The phone going to sleep after inactivity
  • etc…

I suspect that learning the Activity lifecycle is one of the more challenging aspects of Android development. I hope this and future diagrams help.

See Also…

OpenID is Only Good in Theory

I got myself a shiny new OpenID account from Yahoo, and so far it only worked on 1 out of 3 sites:

  • Pragmatic Bookshelf – yep, worked
  • DZone – nope, does not work
  • Blogger – nope, does not work

Perhaps one day the whole world will come together and agree to implement the spec in a consistent way so OpenID accounts work everywhere. But so far, I’m not even marginally impressed.

Introduction to Android

Here are my slides from today’s OCI Java Lunch:

My slides are pretty sparse, so I’m not sure how much value these are to people who were not there. During the second half of the presentation, I showed several code samples in Eclipse, hooked up my G1 phone and installed an app, and showed the CompareEverywhere application.

Oh yeah…I made these slides in Keynote. I then exported as PowerPoint, then uploaded to Google Docs. Some of the font effects were lost, and I had to indent the text a bit in the code samples. But overall, the conversion went very smoothly. Nice work, Google!