0
我試圖從現有活動中啓動新活動,但是我找到活動未找到異常。Android:使用意圖開始新活動時未找到活動
這是我的代碼和logcat錯誤的剝離版本。任何幫助將非常感激。
MainActivity
public class MainActivity extends FragmentActivity {
/* (non-Javadoc)
* @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startActivity(new Intent(this, TermsAndConditions.class));
}
....
}
NewActivity
public class TermsAndConditions extends Activity{
/* (non-Javadoc)
* @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.terms_and_conditions);
}
}
Android清單
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:screenOrientation="sensorLandscape">
<activity
android:name=".MainActivity"
android:screenOrientation="landscape"
android:configChanges="keyboardHidden|orientation"
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:label="@string/app_name" android:name=".TermsAndConditions"></activity>
</application>
</manifest>
logcat的
04-02 16:48:43.255: E/AndroidRuntime(20856): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.example.app.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.app/com.example.app.TermsAndConditions}; have you declared this activity in your AndroidManifest.xml?
嗯,在這裏看起來很好。仔細檢查您的拼寫(如果您的實際代碼中存在拼寫錯誤)並嘗試清理您的項目。 – Sam
[ActivityNotFoundException?]的可能重複(http://stackoverflow.com/questions/4121450/activitynotfoundexception) – jprofitt