2013-02-07 98 views
-2

當我嘗試更改活動時出現錯誤。它曾經工作,但我不知道發生了什麼。活動未更改 - 崩潰

我看了25行,但沒看到有什麼問題。難道我做錯了什麼?

02-07 20:05:02.414: E/AndroidRuntime(1278): FATAL EXCEPTION: Thread-105 
02-07 20:05:02.414: E/AndroidRuntime(1278): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.MainActivity } 
02-07 20:05:02.414: E/AndroidRuntime(1278):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622) 
02-07 20:05:02.414: E/AndroidRuntime(1278):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417) 
02-07 20:05:02.414: E/AndroidRuntime(1278):  at android.app.Activity.startActivityForResult(Activity.java:3370) 
02-07 20:05:02.414: E/AndroidRuntime(1278):  at android.app.Activity.startActivityForResult(Activity.java:3331) 
02-07 20:05:02.414: E/AndroidRuntime(1278):  at android.app.Activity.startActivity(Activity.java:3566) 
02-07 20:05:02.414: E/AndroidRuntime(1278):  at android.app.Activity.startActivity(Activity.java:3534) 
02-07 20:05:02.414: E/AndroidRuntime(1278):  at com.example.quizapp.Splash$1.run(Splash.java:25) 

這是我Splash.java類:

package com.example.quizapp; 

import com.example.quizapp.R; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 

public class Splash extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.splash); 

    Thread t1 = new Thread() { 
     public void run() { 
      try { 
       sleep(3000); 
      } catch (InterruptedException e) { 
       e.printStackTrace(); 
      } finally { 
       Intent openMainActivity = new Intent(
         "android.intent.action.MainActivity"); 
       startActivity(openMainActivity); 
      } 
     } 
    }; 
    t1.start(); 
    } 

    @Override 
    protected void onPause() { 
     super.onPause(); 
     finish(); 
    } 
} 

回答

1

嘗試改變這種代碼

Intent openMainActivity = new Intent(
         "android.intent.action.MainActivity"); 

與這一個

Intent openMainActivity = new Intent(Splash.this, MainActivity.class); 

還要確保您已聲明您的清單f中的MainActivity ILE。

+0

感謝。它現在的作品:) – IlhamiD

+0

不客氣。 – Aram

0
package com.example.quizapp; 

這是您的包裝。

您需要引用全班+包名稱:

Intent openMainActivity = new Intent(
         "com.example.quizapp.MainActivity");