Some starteri-help for android?

I would like to learn coding on Android, but Android is difficult and scary. Developing for Android is often described as a cumbersome task - I know Java, but Android is apparently a little more difficult than "mere" Java complexity.
1 answer

Simple Hello-World-App on Android

Let's start with what you need first.

  • An Android phone, e.g. Samsung Nexus S or Galaxy Nexus
  • An IDE. Use Eclipse for Java EE.
  • The Eclipse ADT plugin (Android Dev Tools), available from Eclipse's own Package Installer.
  • The Android SDK-Tools, available from here

Install all software named in the upper list in this order. At one point, you'll be asked which Android versions you want to develop for. It is always a good idea to be on top of things, but don't forget to be compatible (more about this later). After you've done this, check whether any Android SDK-components are missing: In Eclipse, open "Window", "Android SDK Manager", and check whether the Android versions chosen by you are there.

The next step is to create the Hello-World-program. For this, in Eclipse: Open "File", "New", "Android Application Project" (might be hidden in "Other" the first time you open it). In this window, you'll have to make two important choices: What SDK-Version should be the "Minimum Required SDK"? What is the oldest Android phone you want your Hello-World-App to be compatible with? And: What is the "Target SDK"? For which SDK-Version do you want to develop this specific app.

Some words to Android-App-anatomy (or physiology): Every App consists of a number of "Activities", which interact wich each other by "Intents" and "Handlers". A lower layer, consisting of the "Service" and "AsyncTasks", is here to bring order to the chaos. Activities can be paused and resumed. Views are defined by XML-Files.

Now to the Hello-World-display: First, create a view in Eclipse. You should see an Android display. Name the resulting XML-file e.g. "activity_main.xml". Drag a Text-Field into the display of the phone. In the code, you should see an XML-particle, like:

< Text View
android:text="Hello World!" />

In the java-File of your main activity, be sure to set the view you've just created to be displayed on start-up. For this, you'll have to add a line of code to the activity's onCreate-method:

protected void onCreate(Bundle savedInstanceState) {

That's it. Plug in your phone, if you haven't already, and run the code in Eclipse. It should automatically deploy it to the phone - where an app symbol should appear. Run it, voilà!