Tell It To The Blog

To content | To menu | To search

Wednesday 28 March 2012

How do I get started on Android?

More often than you'd expect, I am asked how to get started developing for Android. Just saying "http://developer.android.com/" is a bit too trite, so here it is in a bit more detail.

1. It is pretty much essential to know the syntax of the Java programming language. Knowing how to read and write XML documents is only slightly less important. You won't go far in Android without knowing these two basic technologies.

2. Subscribe to android-developers and Stack Overflow. Seriously.

3. Install the Android SDK. Make sure you have all the prerequisites on your computer before you install. Create and start up an AVD.

4. Read everything in the Dev Guide under the heading "Android Basics".

5. Read and complete all the Tutorials.

6. Create some new Android projects based on the samples and start experimenting.

There's obviously a lot more: Useful Android-oriented books, blogs and tutorials abound. The above makes a good foundation to get you started.

Friday 25 March 2011

Super Simple Fragments

Fragments are one of the new tablet-oriented UI features in Android 3.0 "Honeycomb". The Android developer documentation illustrates fragments with a simple but useful sample program.

Sometimes usefulness impedes understanding. Here is a useless program that will allow you to start using fragments in the simplest possible way. Follow along as I convert the Android SDK's standard "Hello World" skeleton app to use fragments.

Step 1: Hello World!

  • 1.1. Use the Eclipse IDE to create a new Android project.
  • 1.2. Choose Android 3.0, and use Min SDK Version 11.

Step 2: Layout

  • 2.1. Open res/layout/main.xml.
  • 2.2. Cut out the TextView and save it in a new XML resource: hello_frag.xml.
  • 2.3. Be sure to add the Android XML namespace in the TextView. The resulting file should look like this:
<?xml version="1.0" encoding="utf-8"?>
<TextView
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="@string/hello"
/>
  • 2.4. Now add this fragment to main.xml in the LinearLayout where the TextView used to be.
<fragment class="[your main Activity class name]$SSFFragment"
   android:id="@+id/frag"
   android:layout_width="match_parent"
   android:layout_height="match_parent" />

Step 3: Program code

  • 3.1. Open the source code file in src/[your package name]/[your main Activity class name].java.
  • 3.2. Add this private static subclass to handle the Fragment.
/* Add a class to handle fragment */
public static class SSFFragment extends Fragment {
   @Override
   public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      // Inflate the layout for this fragment
      View v = inflater.inflate(R.layout.hello_frag, container, false);
      return v;
   }
}
  • 3.3. In the Eclipse menu bar, select Source > Organize Imports.

Step 4: Run!

Congratulations, you are using Fragments.

Step 5: Extra credit - make it backward-compatible

  • 5.1. If you haven't already, in the Eclipse IDE, select Window > Android SDK and AVD Manager and install the Android Compatibility package.
  • 5.2. In the Eclipse menu bar, select Project > Properties > Java Build Path > Libraries.
  • 5.3. Select Add External Jars... and choose android-support-v4.jar from your file system.
  • 5.4. In your source code file, change "Activity" to "FragmentActivity".
  • 5.5. Select Source > Organize Imports again.
  • 5.6. Build and run.

Note that adding the compatibility library will have consequences:

  • It will bulk up your application. In the Hello World example, classes.dex grows from 4k to 119k.
  • Your application will not benefit from improvements to Fragments in later updates of Android.

Step 6: Extra extra credit - update deprecated layout

  • 6.1. In the TextView, replace "fill-parent" with "match-parent".

That's it! Super simple, na?

Racing ahead with Android

Racer Android

Today, the blog begins moving in a new direction: Androidward. From time to time, if I've had enough coffee, a tidbit about Android app development may appear here. If I haven't had any coffee, or if I'm just feeling ornery, I'll probably write about ferrets instead.

Wednesday 23 March 2011

No comment

Due to an infestation of spam, comments have been disabled. If you want to know who can sell you counterfeit fashion goods, I have links for you.

Sunday 2 May 2010

Expressly Forbidden

Things I wish I had known before coming to Germany #1: Do not take American Express Travelers' Cheques to Germany.

20 years ago, AmEx TCs were absolutely the way to go in Europe. Better than cash, and we always got great exchange rates at local AmEx travel offices.

No more.

Cheques are anathema to German businesses. Commerce here is done via cash, debit cards or direct bank transfer. Nobody wants to touch a cheque, and it doesn't matter that Travelers' Cheques are supposed to be just like cash. Germany's largest bank, one of the 50 largest corporations in the world, will not take them. That should tell you something. AmEx closed all their offices in Germany a few years ago. That should tell you something too.

It took us several days to find an institution that would both accept our travelers' cheques and give us a good rate. Apparently this was a strange request for them, because the cashier followed a Xeroxed protocol that took over two hours and involved discussions with management, phone calls, and generally handling our cheques with the sort of care usually reserved for volatile organic chemicals.

Don't come to Germany expecting to put everything on your credit card, either. This was another great strategy years ago, but fees are a lot higher now. Haven't you heard there was a financial meltdown? Lenders are making up their losses any way they can.

Long story short, if you are coming to Germany for a short time and need a few hundred dollars every once in a while, bring an ATM card. Not a debit card, not a check-card, a plain-vanilla ATM card from your bank. If you need a few thousand dollars, use a wire transfer.

Saturday 1 May 2010

No such thing as a free lunch

Whatever you pay for stuff in U.S. dollars, it's about the same number of Euros in Germany. Since €1 is currently worth about $1.34, you'd think everything is 34% more expensive. But U.S. retail prices are quoted before sales tax, which is currently over 9% in Santa Clara, whereas the 20% value-added tax is included in Germany. Taking that into account, on average you're really only paying about 23% more.

Even with the exchange rate, some things are cheaper in Germany than in the U.S., like booze and coffee. A pint of beer can be had for half a buck. I could learn to like it here.

Getting There

There's one flight per day from San Francisco non-stop all the way to Munich. Operated by Lufthansa, but you can book through United. And it leaves SF at about 9 PM. Traveling with a baby, this is the way to go. And they have movies on-demand in coach. Bonus!

Sunday 25 April 2010

Going Deutsch

Seems I'm going to spend the next 18 months in Germany. Watch this space for some articles about things I'm glad they told me, things I wish they had told me, and things I wish they hadn't told me.

Wednesday 11 November 2009

Blogging is passe

Wouldn't you know, within minutes of starting this blog, I discovered that every single one of my friends is using Facebook.

Friday 24 April 2009

My all-time favorite knock-knock joke

Try this with any 4-year-old and see if you do not agree that this is the best knock-knock joke ever.

Knock, knock. Who's there?
Interrupting cow. Interrupting cow wh...
Moo!

Wednesday 22 April 2009

Happy Earth Day

Today is Earth Day, if all the news reports can be believed. I'm celebrating Earth Day by riding my bicycle to work. Those who know me will realize this isn't especially newsworthy. Given that I have driven my car to work on the last 3 Bike To Work Days, and probably won't bike this year either, I figure I deserve partial credit for lack of irony.

Wednesday 8 April 2009

No. 13 Baby: You Oughta Know

Last Saturday we gave Pam a rock and roll baby shower. Our friends Ted and Vicki provided the house and, in lieu of stupid shower games, a PS3 and Harmonix Rock Band 2. We like to think a good time was had by all. Three people who had not previously played Rock Band said they were tempted to buy it.

Sincere thanks to everyone who came.

It seemed appropriate to rock out to baby-themed songs, so I set out to compile a list of songs in the Rock Band catalog containing "baby" in the title, band name, or lyrics. We actually played 10 or 15 of these at the party.

The "King of Baby" award goes to Stevie Ray Vaughan, whose 10-track album "Texas Flood" contains three instrumentals and seven "baby" songs. First runner-up honor goes to Roy Orbison, with four out of six.

I'm sure you are burning up with curiosity; I know I am. Without further ado, here is my list of Rock Band "baby" songs.

Song Title Artist
(Don't Fear) The Reaper Blue Öyster Cult
3 Dimes Down Drive-By Truckers
Ace of Spades '08 Motörhead
Action Sweet
All Right Now Free
Any Way You Want It Journey
Are You Gonna Go My Way Lenny Kravitz
Bad to the Bone George Thorogood & the Destroyers
Blood Sugar Sex Magik Red Hot Chili Peppers
Break My Heart Nikko
Call Me Blondie
Calling Dr. Love Kiss
Can't Let Go Lucinda Williams
Cherry Bomb Runaways
Claudette Roy Orbison
Countdown to Insanity H-Blockx
Crushcrushcrush Paramore
Dani California Red Hot Chili Peppers
Dead Pixies
Dirty Pool Stevie Ray Vaughan and Double Trouble
Doin' That Rag Grateful Dead
Don't Go Away Mad (Just Go Away) Mötley Crüe
Don't Make Me Wait Locksley
Drain You Nirvana
El Scorcho Weezer
Enter Sandman Metallica
Feed the Tree Belly
Flirtin' with Disaster Molly Hatchet
Franklin's Tower Grateful Dead
Girls on Film Duran Duran
Go Your Own Way Fleetwood Mac
Hard to Handle Black Crowes
Hell in a Bucket Grateful Dead
Hella Good No Doubt
Hey Baby No Doubt
Hey Pixies
I Fought the Law Clash
I Think I'm Paranoid Garbage
I Wanna Be Your Man Endeverafter
I'm Cryin' Stevie Ray Vaughan and Double Trouble
Kickstart My Heart Mötley Crüe
Kids in America Muffs
Kool Thing Sonic Youth
La La Love You Pixies
Leaving Here Who
Little Sister Queens of the Stone Age
Livin' on a Prayer Bon Jovi
Love Struck Baby Stevie Ray Vaughan and Double Trouble
Mary Had a Little Lamb Stevie Ray Vaughan and Double Trouble
Moonage Daydream David Bowie
Mountain Song Jane's Addiction
My Generation (Live at Leeds) Who
Next to You Police
Night Lies Bang Camaro
No. 13 Baby Pixies
Oh, Pretty Woman Roy Orbison
Ooby Dooby Roy Orbison
Outside Tribe
Pleasure (Pleasure) Bang Camaro
Precious Pretenders
Pretty Fly (for a White Guy) Offspring
Pride and Joy Stevie Ray Vaughan and Double Trouble
Rescue Me Buckcherry
Rock'n Me Steve Miller Band
Screaming for Vengeance Judas Priest
Sick, Sick, Sick Queens of the Stone Age
Simple Man Lynyrd Skynyrd
Slice of Your Pie Mötley Crüe
Song with a Mission Sounds
Suck My Kiss Red Hot Chili Peppers
Sugar Magnolia Grateful Dead
Tell Me Baby Red Hot Chili Peppers
Tell Me Stevie Ray Vaughan and Double Trouble
Texas Flood Stevie Ray Vaughan and Double Trouble
The Greatest Man That Ever Lived Weezer
The Greeting Song Red Hot Chili Peppers
The Joker Steve Miller Band
Thrash Unreal Against Me!
Thunderstruck (Live) AC/DC
Truckin' Grateful Dead
Underneath It All No Doubt
We Care a Lot Faith No More
Why Do You Love Me Garbage
You Got It Roy Orbison
You Oughta Know Alanis Morissette

Tuesday 7 April 2009

Monday Night With Everyone

On the first Monday of every month, a bunch of my friends get together for dinner. The gathering can be as small as 3 or 4, but often exceeds 10 attendees and includes people who don't show up to most of our other gatherings. Ted and Mikey, who started this tradition, developed an interesting and surprisingly effective set of rules for getting a herd of geographically disparate people to converge on an arbitrary location at an arbitrary time.

  1. An email list is assembled with everyone who might conceivably want to attend the event.
  2. On the morning of the big day, someone sends an email to someone on the list, asking them to pick a restaurant and a time to meet.
  3. That person indicates their selection by replying to the list.
  4. Anybody may veto the selection, but must provide an alternative selection.
  5. Any number of vetoes may happen before a selection remains unchallenged.
  6. A person who proposed a selection that was vetoed may not later re-propose the same selection in a veto of their own.

For logistical reasons, vetoes are cut off and a final selection must be established by around 4:30 or so. Messages do cross in the mail (for instance, two people may be invited to choose by different participants simultaneously), but this rarely causes any problem. Vetoes are also rare. The chosen person may pass and not make a recommendation. In this case, it is considered polite to designate another person to make the choice. If the chosen person doesn't respond in a timely manner, the process may restart with someone else.

For these large monthly meet-ups, people usually just pay for their own food. But when the number of participants is small (5 or less, for example) and fairly constant, and the number of occasions is greater (weekly, for example), there is a more interesting approach. Everyone tosses a coin to see who will pay for dinner. There is a set of rules for this, too.

  1. If there are two participants, one tosses a coin and the other calls it.
  2. If there are more than two participants, everyone tosses a coin.
  3. The majority (composed of the greatest number of people who got the same side up) drop out.
  4. If the two sides are exactly equal in number, then everyone tosses again.
  5. The previous rules iterate until only one person is left.
  6. That person pays for dinner for everyone.

If the pool of people participating in this scheme is relatively uniform (most of the same people most of the time), then the random process all but guarantees that in the long run, this will average out to everyone paying about the same. It's different from a typical lottery in that there's only one loser and everyone else is the winner. But it's the same in that, in the end, no one stays rich.

Thursday 22 January 2009

No-Drama Pledge

You don't like people wasting your time. (If this is not the case, I can probably help you out.) My pledge to you, as the writer of this blog, is that I will not waste your time with meaningless navel-gazing blog posts. I won't publicly agonize over what color nail polish to use (don't paint it), how my ex is mistreating me (can't we all just get along), or what to eat for breakfast (coffee and croissant at Bellano). This blog is for things that matter (me me me, it's all about me). Thanks for reading.

Sunday 18 January 2009

You would be...?

Thank you for choosing to devote part of your life to reading this blog. On the off-chance that you are the one person who found it by some means other than being sent here by me, please allow me to provide some basic facts about myself. Me, me, me, it's all about me.

In many ways a typical Silicon Valley geek, I...

  • am male, married, 40 years old.
  • live in Silicon Valley, California.
  • work in the computer industry as a software engineer.
  • sing baritone in a community choir.
  • play guitar, not very well.
  • am fond of ferrets.
  • have participated in NaNoWriMo four times.
  • ride to work on a recumbent bicycle.
  • play D&D.
  • enjoy sushi and anime.
  • am expecting my first baby in about 3 months.

That's enough for now. If I told you everything at once, you'd have no reason to come back. And if you are that marvelous stranger who came here voluntarily, won't you please leave a comment or send email and introduce yourself?

So it begins

Yeah, yeah, it's my blog.  I've had at least six other blogs before.  Why is this one going to be any different?  That's the beauty of it: it won't.  Hah.