所以我有一个应用程序,并希望连接到活动但由于某种原因它不会连接并且它一直崩溃
Thread logotimer = new Thread(){
public void run(){
try{
sleep(1500);
Intent logoLessius = new Intent("com.theludus.Mainpage");
startActivity(logoLessius);
}
catch(InterruptedException e){
e.printStackTrace();
}
finally{
finish();
}
}
};
logotimer.start();
这是必须连接下一页的代码,接下来是我的android清单
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<activity
android:name="com.theludus.Startup"
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.theludus.Mainpage"
android:label="@string/title_activity_mainpage" >
</activity>
<activity
android:name="com.theludus.NewGame"
android:label="@string/title_activity_new_game" >
</activity>
<activity
android:name="com.theludus.GamePage"
android:label="@string/title_activity_game_page" >
</activity>
</application>
这是我的logcat所说的
05-12 15:22:05.393: E/AndroidRuntime(26537): FATAL EXCEPTION: Thread-2649
05-12 15:22:05.393: E/AndroidRuntime(26537): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.Mainpage }
05-12 15:22:05.393: E/AndroidRuntime(26537): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
05-12 15:22:05.393: E/AndroidRuntime(26537): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
05-12 15:22:05.393: E/AndroidRuntime(26537): at android.app.Activity.startActivityForResult(Activity.java:3190)
05-12 15:22:05.393: E/AndroidRuntime(26537): at android.app.Activity.startActivity(Activity.java:3297)
05-12 15:22:05.393: E/AndroidRuntime(26537): at com.theludus.Startup$1.run(Startup.java:21)
答案 0 :(得分:1)
更改
<activity
android:name="com.theludus.Mainpage"
android:label="@string/title_activity_mainpage" >
</activity>
到
<activity
android:name="com.theludus.Mainpage"
android:label="@string/title_activity_mainpage" >
<intent-filter>
<action android:name="com.theludus.Mainpage" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
当仅使用名称调用活动时,它将在活动的intent-filter中定义。否则,也可以使用以下方法调用活动。
Intent intent = new Intent(getApplicationContext(),ActivityName.class);
startActivity(intent);