我正在學習android編程,並且正在創建一個應用程序,該應用程序以啓動畫面開始並在此之後加載菜單類。問題是我得到這個例外類未找到例外Android
06-04 10:59:37.166: E/AndroidRuntime(926): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.em.example1.MENU" on path: /data/app/com.em.example1-1.apk
我明白什麼是異常狀態,但我不明白爲什麼會這樣。在我的啓動畫面I類加載這樣
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread timer = new Thread() {
public void run() {
try {
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
Intent mainApp = new Intent("com.em.example1.MENU");
startActivity(mainApp);
}
}
};
timer.start();
和菜單類菜單活動在清單文件中這樣定義
<activity
android:name="com.em.example1.MENU"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.em.example1.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
,當我裝兩個按鈕和一個主要活動標籤一切工作正常。但是,當我改變它(在我的啓動畫面活動),所以它會加載菜單活動它不斷給我這個錯誤。
在此先感謝
並且菜單類被命名爲MENU?請張貼該活動。 –
http://developer.android.com/training/articles/perf-anr.html。在線程中使用sleep()是一個糟糕的設計。檢查鏈接 – Raghunandan
http://stackoverflow.com/questions/16643177/changing-image-in-imageview-using-threads/16643267#16643267。爲啓動畫面。使用飛濺被認爲是邪惡的一些http://cyrilmottier.com/2012/05/03/splash-screens-are-evil-dont-use-them/ – Raghunandan