0

我不断发现没有发现处理意图致命错误的活动。我没有其他错误并声明所有意图和活动。怎么了?

这是我的 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(); 
   }
}

这是我的 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(); 
     }
 };         
     }

这是清单:

    <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>

这是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)
4

2 回答 2

0

logcat 告诉我们它在运行 Intent MENU 时遇到问题。我相信它区分大小写,所以请尝试将此行添加到您的 Activity :

像这样:

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

所以你的电话被正确识别。

另外:您正在形成的另一个意图是寻找不同的类,如此处所述:

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

不在您的清单中。即使他们是,他们也不会形成良好的。

根据您迄今为止的清单,您可能会改变

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

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

例如,并在您将活动添加到清单+项目时添加其他选项。

于 2013-06-17T22:51:10.153 回答
0

尝试:

Intent openClubChoice = new Intent(ClubChoice.this, Menu.class);
于 2013-06-17T22:52:21.953 回答