Oct 28, 2009
Pennsylvania, USA
I am sorry, this is probably a very basic question, but my first Android program keeps getting hung when trying to switch to another activity. I have gone through several tutorials and the documentation, and I am starting to think that I am either leaving something basic out, or I am mixing methods too much. Hopefully someone can spot the problem, and show me where I am messing up.

So far, the app consists of two classes, Index and Statistics. Index is the default class, and gives the user a list of options. Statistics goes to the web, downloads an XML file of data, and displays it to the user. Both extend Activity and use onCreate and appear to work on their own.

In the manifest, I have defined a custom action for the Statistics activity:
		<action android:name="com.package.project.action.SHOW_STATISTICS" />

In the index class, I have a method that receives a button click and tries to start the Activity by creating a new Intent:
if (R.id.statsButton == v.getId()) {
	// The user wants to view the statistics, create an Intent
	try {
		startActivity(new Intent("com.package.project.action.SHOW_STATISTICS"));
	} catch (ActivityNotFoundException e) {

When this code runs, the test dialog is displayed, indicating an ActivityNotFoundException occurred. Is there somewhere else that com.package.project.activity.SHOW_STATISTICS needs to be declared for example?

Any thoughts?

Thanks in advance for reading, and any suggestions/guidance you can offer.
Did you remember to define your activity in the manifest?
The first one is added for you automatically

They go within the <activity></activity> tags.
Try adding the following to your intent filter:
<category android:name="android.intent.category.DEFAULT" />

Alternatively, you could use Intent.setComponent or Intent.setClass to explicitly say what class/component you want to handle the intent.
regulatre, yes, I added it to the manifest using the code in the first snippet. Does the syntax look correct?

Dave, thanks, I will try adding the category. I ended up using the setClass method, since I think that is probably more appropriate in this instance, but as the application becomes more complex, being able to use an implicit Intent will probably become necessary, so I hope to be able to get it working. I will try the category and post back with the results.
Ok, apparently it was a very stupid error on my part.... the manifest was missing a period...

android:name="Statistics" should have been android:name=".Statistics"

Thanks for the help and suggestions.