15th July 2010
Permalink: http://chrismacpherson.com/archives/21/
Following the 'Quick Start' guide in the Android development docs quickly got me stuck. I couldn't get the emulator to load my app, after clicking run in Eclipse the Android emulator loaded up, displayed 'Android' and then loaded up the device desktop as normal. But my app was nowhere to be seen.
After some Googling and advice from here and there I eventually worked out it was to do with the app manifest being incorrect, or not providing the correct details to describe the app properly to the OS. I got to this section in the Android documentation which indicates the use of 'Intents'. An Intent is 'a passive data structure holding an abstract description of an operation to be performed...' and in our case '...Activities that can initiate applications have filters with "android.intent.action.MAIN" specified as the action. If they are to be represented in the application launcher, they also specify the "android.intent.category.LAUNCHER" category'.
So, I added this INSIDE my <activity> element of my manifest XML file:
<intent-filter>
<action android:name="code android.intent.action.MAIN" />
<category android:name="code android.intent.category.LAUNCHER" />
</intent-filter>
I subsequently read this which explains the whole process in more detail. "An activity is set up as the entry point for a task by giving it an intent filter with "android.intent.action.MAIN" as the specified action and "android.intent.category.LAUNCHER" as the specified category. (There's an example of this type of filter in the earlier Intent Filters section.) A filter of this kind causes an icon and label for the activity to be displayed in the application launcher, giving users a way both to launch the task and to return to it at any time after it has been launched."
Read more about this here http://developer.android.com/guide/topics/fundamentals.html under the "Starting tasks" sub-header
Comments