Make an Android App in Ten Minutes
Make sure you follow the installation guide before proceeding.
- First we need to create a project. In TextMate > Bundles > Android, click on New Project and select a Workspace. A workspace is basically the folder you want to generate/save your project in. Now enter "HelloWorld" for "Project Name" and "HelloWorldActivity" for "Activity". Select "android-5" as the Build Target to target Android 2.0 phones and press Create to generate the files.
- TextMate will open the HelloWorld folder and view the file HelloWorld/src/com/example/HelloActivity.java. That's your Activity class, an Activity is a class that can run and do work. Change the code to the following:
package com.example; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class HelloActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Cow says Moo"); setContentView(tv); } }
-
Now let's create a Android Virtual Device to run our app. In TextMate > Bundles > Android, click on New Device and fill in "AwesomeAndy" for "Device Name" and select "android-5" for the "Build Target" to create a Android 2.0 virtual device. Press Create.
- In TextMate > Bundles > Android, click on Build App and select "debug" as the build type. The project will compile as a .apk file in HelloWorld/bin, be ready for installation.
-
In TextMate > Bundles > Android, click on Launch Emulator. Click on "AwesomeAndy" to launch the emulator, a dialog will come up asking whether you want to wipe the data (clear the data partition and any old data). Click "yes" and let the emulator launch. It will take a couple minutes for the emulator to boot up. If you get messages in the emulator about non-responding devices, just press "wait".
- In TextMate > Bundles > Android, click on Install App, two dialogs will come up. The first one will ask you whick .apk file to install, choose the one you just created "HelloWorld-debug.apk". The second dialog will ask you which device to install on. Since you've only have one installed, just leave it at the first option and press OK.
-
Time to view our app! Navigate to the apps on the phone, and click on HelloActivity.