好吧,當我插入我的手機到電腦啓動應用程序,睡眠()完成後它崩潰與底部顯示的錯誤。我認爲您需要的所有代碼都顯示在引文中。開始一個新的活動,但我得到一個ActivityNotFoundException
真的很困惑爲什麼我得到這個問題。我有我的mainActivity.java文件看起來像這樣:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Thread timer = new Thread(){
public void run(){
try{
sleep(1000);
} catch (InterruptedException e){
e.printStackTrace();
}finally{
Intent intent = new Intent("com.worcestershire.android.Pagetwo", null);
startActivity(intent);
}
}
};
timer.start();}
第2頁看起來是這樣的:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@raw/logo"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="This is Activity 2" />
<Button android:text="Previous"
android:id="@+id/Button02"
android:layout_width="250px"
android:textSize="18px"
android:layout_height="55px">
</Button>
</LinearLayout>
我的清單看起來是這樣的:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.worcestershire.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/maps_launcher"
android:label="@string/app_name" >
<activity
android:name="com.worcestershire.android.MainActivity"
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=".PAGETWO"
android:label="@string/app_name" >
</activity>
</application>
</manifest>
繼承人的日誌:
01-04 12:27:05.711: W/dalvikvm(25483): threadid=9: thread exiting with uncaught exception (group=0x4001d5a0)
01-04 12:27:05.711: E/AndroidRuntime(25483): FATAL EXCEPTION: Thread-10
01-04 12:27:05.711: E/AndroidRuntime(25483): android.content.ActivityNotFoundException: No
Activity found to handle Intent { act=com.worcestershire.android.Pagetwo }
01-04 12:27:05.711: E/AndroidRuntime(25483): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1569)
01-04 12:27:05.711: E/AndroidRuntime(25483): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1539)
01-04 12:27:05.711: E/AndroidRuntime(25483): at android.app.Activity.startActivityForResult(Activity.java:2901)
01-04 12:27:05.711: E/AndroidRuntime(25483): at android.app.Activity.startActivity(Activity.java:3007)
01-04 12:27:05.711: E/AndroidRuntime(25483): at com.worcestershire.android.MainActivity$1.run(MainActivity.java:43)
任何幫助將是你的SE。乾杯!
你的建議做一兩件事,但你的活動名稱也不同...... – evilone 2012-01-04 12:38:50
@evilone,對不起,我我編輯了我的答案。 – Egor 2012-01-04 12:41:02