[問題] 我屁股著火了 ActivityNotFoundException
我在Activity中設計一個按鈕
打算讓他在按下去時開啟另一個Activity
結果一執行到 startActivity(); 的時候
就會吐 ActivityNotFoundException
查了一下,幾乎所有說明都寫:
要在 AndroidManifest.xml中註冊才不會出錯
問題是.....
我已經有註冊了啊!
很奇怪,我之前加別的Activity到程式中都沒出問題
搞不清楚為什麼這次就出問題了。
看了整個下午還是找不出原因,想請大家幫忙看一下
MapShow.java
//========================================
package com.seelife.clentf02;
public class MapShow extends MapActivity implements LocationListener
{
(....中略.....)
Intent intent = new Intent();
intent.setClass(MapShow.this,UserShow.class);
startActivity(intent);
(....中略.....)
}
AndroidManifest.xml
//========================================
<?xml version="1.0" encoding="utf-8"?>
<manifest .........>
<application ...................>
<activity ........> </activity>
<service ..........>
<intent-filter >
<action ................ />
</intent-filter >
</service >
<activity android:name=".MapShow">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="UserShow" android:label="@string/app_name">
</activity>
</application>
</manifest>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.233.155.16
推
10/01 20:30, , 1F
10/01 20:30, 1F
→
10/01 20:31, , 2F
10/01 20:31, 2F
→
10/01 20:33, , 3F
10/01 20:33, 3F
→
10/01 20:34, , 4F
10/01 20:34, 4F
推
10/01 20:34, , 5F
10/01 20:34, 5F
推
10/01 20:36, , 6F
10/01 20:36, 6F
→
10/01 20:37, , 7F
10/01 20:37, 7F
→
10/01 20:38, , 8F
10/01 20:38, 8F
→
10/01 20:38, , 9F
10/01 20:38, 9F
→
10/01 20:40, , 10F
10/01 20:40, 10F
→
10/01 20:40, , 11F
10/01 20:40, 11F
推
10/01 20:55, , 12F
10/01 20:55, 12F
→
10/01 20:57, , 13F
10/01 20:57, 13F
→
10/01 20:58, , 14F
10/01 20:58, 14F
剛剛用重構把UserShow重新命名後,發現
intent.setClass(MapShow.this,UserShow.class);
↑
這裡沒變
<activity android:name="UserShow" android:label="@string/app_name">
↑
這裡變了
把滑鼠移上去,才發現他指的是我另一個檔案中的innerclass 也叫做UserShow
public final class CTag
{
(.....中略.....)
public static final class UserShow
{
public static final String Uid ="UserShowUid";
(.....中略.....)
}
(.....中略.....)
}
※ 編輯: LaPass 來自: 125.233.155.16 (10/01 21:03)
→
10/01 20:59, , 15F
10/01 20:59, 15F
→
10/01 21:02, , 16F
10/01 21:02, 16F
→
10/01 21:03, , 17F
10/01 21:03, 17F
→
10/01 22:48, , 18F
10/01 22:48, 18F
→
10/01 23:20, , 19F
10/01 23:20, 19F
→
10/02 00:22, , 20F
10/02 00:22, 20F