Android Development Notes
i just realized it totally looks like he’s winking

i just realized it totally looks like he’s winking

Awesome! Having a test device rules.

So, this warning was plaguing me for a while:

ActivityManager: Warning: Activity not started, its current task has been brought to the front

“What is this crap?” I thought.  “Why won’t the emulator start?!”

Then I looked down at my G1, which I had plugged in to my computer via USB to charge, and realized that my app was already running on my phone.  I have no idea how this happened.  Eclipse just found my phone plugged in and handed it the app, which it happily ran.  Too effing cool!

“Hello world” achieved!  I’m calling it a night.

XML and GUI Building

Ugh, I guess I will assent to working with XML to the extent that it is necessary.  Why would you use XML for an intra-IDE data format?!  For God’s sake, it’s an IDE!  The data format can be whatever you want!  Just make the interface not suck, and—oh.  Well, there’s my answer.

The raw basics for layout actually aren’t bad:


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical" 
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/MyColor"
> <EditText android:id="@+id/EditText01" android:layout_height="wrap_content" android:layout_width="fill_parent" android:inputType="numberSigned|numberDecimal"></EditText> <RadioGroup android:id="@+id/RadioGroup01" android:layout_width="wrap_content" android:layout_height="wrap_content"> <RadioButton android:id="@+id/RadioButton01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/celsius" android:checked="true"></RadioButton> <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/fahrenheit"></RadioButton> </RadioGroup> <Button android:id="@+id/Button01" android:layout_height="wrap_content" android:onClick="@string/buttonHandler" android:layout_width="wrap_content" android:text="@string/calc"></Button> </LinearLayout>

I’m sure it gets hairier once you start building really complex and functional interfaces, but this doesn’t have any of the bloat that usually makes me terrified of XML.  Also, I like the way it separates constants like strings and colors from the actual layout by letting you reference an XML file (as in android:text=”@string/someconstant”).  I wonder how much of this is Eclipse, how much of it is Eclipse Helios, and how much of it is the Android SDK.

Setting up the SDK

My Development Platform: Windows XP SP3

My Testing Device: G1 with CyanogenMod-4.2.15.1 (running Android 1.6)

This is mostly a summary of what I found here and here.

I’ve never done Java development, nor any development with any IDEs, so this was kind of a hassle.  I predict that I’m going to hate working without a command line.

  1. Download the Android SDK from the official Android site.
    1. Extract it.
    2. Run SDK Setup.exe.
    3. It complained about SSL errors, so I cancelled out of everything, went to “Settings” and set “Force HTTPS to be downloaded through HTTP.”
    4. In retrospect, I only needed to download API version 4, which is specifically for Android 1.6. But, I downloaded them all, and it took forever.
  2. Download “Eclipse IDE for Java Developers” (99 MB) from the Eclipse site.  Turns out this is a special flavor of Eclipse called “Helios.”
  3. Download “Java Platform (JDK)” from the Java site.
  4. Install them both.
  5. Open Eclipse, go to Help -> Install New Software.
  6. Select “Android” in the “Work with:” drop down menu.  If “Android” isn’t there, add it with this URL: https://dl-ssl.google.com/android/eclipse/
  7. Install Developer tools and restart Eclipse.
  8. Go to Window -> Android Device and SDK manager, and create a new virtual device for testing.
  9. Go to New -> Other… -> Android -> Project and select your desired API version.
  10. I tried adding some values to res/values/strings.xml, but I was getting NullPointerExceptions.  Some Googling turned up this thread, where the Helios developers apologized for the bug and someone suggests a workaround, which is going to Window -> Preferences -> XML -> XML Files -> Editor and unchecking “Use inferred grammar…”