Saturday, January 22, 2011

Registering Activities in AndroidManifest

Here is one little gotcha that I personally stumbled over briefly (Because I rarely stop to read). Early on when adding new Activities into my Android project I was not defining them in the AndroidManifest.  If you add a new Activity and try to start it in your application without it being defined in the AndroidManifest your application will fail and force shutdown.

Here is the AndroidManifest.xml from my previous ListActivity example.  You can see where each Activity for the TabHost is defined.


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.hummingbird"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Welcome"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".Accounts"
                  android:label="@string/app_name">
        </activity>
        <activity android:name=".Transfer"
                  android:label="@string/app_name">
        </activity>
        <activity android:name=".Alerts"
                  android:label="@string/app_name">
        </activity>
    </application>
</manifest>

No comments:

Post a Comment