smoggers smoggers - 3 months ago 22
Java Question

Android 'fatal error no activity found to handle intent'

I'm constantly getting the no activity found to handle intent fatal error. I have no other errors and declare all intents and activities. What's wrong?

Here is my ClubChoice.java:

package com.prototype.cpgc;

import com.prototype.cpgc.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class ClubChoice extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.background);
Thread timer = new Thread(){
public void run(){
try {
sleep(5000);
}
catch (InterruptedException e){
e.printStackTrace();
}
finally{
Intent openClubChoice = newIntent("com.prototype.cpgc
.MENU");
startActivity(openClubChoice);
}
}
};
timer.start();
}
@Override
protected void onPause() {
super.onPause();
finish();
}
}


Here is my Menu.java:

package com.prototype.cpgc;

import com.prototype.cpgc.R;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;


public class Menu extends ListActivity {

String [] menuChoices = {"Login", "Round Analysis", "Long-Term Analysis", "Help"};

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.background);
setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.
simple_list_item_1, menuChoices));}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {

super.onListItemClick(l, v, position, id);

String optionOne = menuChoices[position];
try{
Class<?> menuClass = Class.forName("com.prototype.cpgc." + optionOne);
Intent menuIntent = new Intent(Menu.this, menuClass);
startActivity(menuIntent);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
};
}


Here is the manifest:



<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<activity
android:name="com.prototype.cpgc.ClubChoice"
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="com.prototype.cpgc.Menu"
android:label="@string/app_name" >

</activity>

<activity
android:name="com.prototype.cpgc.RoundAnalysis"
android:label="@string/app_name" >

</activity>
</application>

</manifest>


Here is the Logcat:

06-18 11:55:45.996: E/Trace(1510): error opening trace file: No such file or directory (2)
06-18 11:55:52.826: E/AndroidRuntime(1510): FATAL EXCEPTION: Thread-87
06-18 11:55:52.826: E/AndroidRuntime(1510): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.prototype.cpgc.MENU }
06-18 11:55:52.826: E/AndroidRuntime(1510): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
06-18 11:55:52.826: E/AndroidRuntime(1510): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
06-18 11:55:52.826: E/AndroidRuntime(1510): at android.app.Activity.startActivityForResult(Activity.java:3370)
06-18 11:55:52.826: E/AndroidRuntime(1510): at android.app.Activity.startActivityForResult(Activity.java:3331)
06-18 11:55:52.826: E/AndroidRuntime(1510): at android.app.Activity.startActivity(Activity.java:3566)
06-18 11:55:52.826: E/AndroidRuntime(1510): at android.app.Activity.startActivity(Activity.java:3534)
06-18 11:55:52.826: E/AndroidRuntime(1510): at com.prototype.cpgc.ClubChoice$1.run(ClubChoice.java:45)

Answer

The logcat tells us it's having trouble running intent MENU. I believe it's case sensitive so, try adding this line to your Activity :

like this:

  <activity
    android:name="com.prototype.cpgc.Menu"
    android:label="@string/app_name" >
        <action android:name="com.prototype.cpgc.MENU" />
</activity>

so your call gets recognized correctly.

Also: The other intent you're forming is looking for different classes, as stated here:

"Round Analysis", "Long-Term Analysis", "Help"

which aren't in your manifest. They wouldn't be well-formed even if they were.

Based on your Manifest thus far, you might change

 String [] menuChoices = {"Login", "Round Analysis", "Long-Term Analysis", "Help"};

to

 String [] menuChoices = {"Login", "RoundAnalysis"};

for instance, and add the other choices as you're adding Activities to your manifest+project.

Comments