我已经在 Android Manifest 中声明了我的所有类,但由于某种原因,我不断收到 ActivityNotFoundException。
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abc.calorieapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".activities.CalorieApplication"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".activities.AActivity"
android:label="@string/title_activity_a"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".activities.BActivity"
android:label="@string/title_activity_b"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".activities.CActivity"
android:label="@string/title_activity_c"
android:screenOrientation="portrait" >
</activity>
<activtity
android:name=".activities.DActivity"
android:label="@string/title_activity_d"
android:screenOrientation="portrait" />
<activity
android:name=".activities.EActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
这是给我带来麻烦的电话
Intent intent = new Intent ( AActivity.this, BActivity.class );
startActivity ( intent );
BActivity.java
package com.wks.calorieapp.activities;
public class BActivity extends Activity
{
private static final String TAG = BActivity.class.getCanonicalName ();
private EditText editSearch;
private Button buttonSearch;
private ViewSwitcher viewSwitcher;
private RelativeLayout viewLoading;
private LinearLayout viewResults;
private TextView textLoading;
private ProgressBar progressLoading;
private ExpandableListView listNutritionInfo;
private enum BActivityView{VIEW_IDLE,VIEW_LOADING,VIEW_RESULTS};
private BActivityView searchActivityView;
@Override
protected void onCreate ( Bundle savedInstanceState )
{
super.onCreate ( savedInstanceState );
this.setContentView ( R.layout.activity_b );
setupView();
setupListeners();
}
完整的堆栈跟踪:
06-22 21:01:50.625: E/AndroidRuntime(18120): FATAL EXCEPTION: main
06-22 21:01:50.625: E/AndroidRuntime(18120): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.wks.calorieapp/com.wks.calorieapp.activities.BActivity}; have you declared this activity in your AndroidManifest.xml?
06-22 21:01:50.625: E/AndroidRuntime(18120): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1511)
06-22 21:01:50.625: E/AndroidRuntime(18120): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1387)
06-22 21:01:50.625: E/AndroidRuntime(18120): at android.app.Activity.startActivityForResult(Activity.java:3195)
06-22 21:01:50.625: E/AndroidRuntime(18120): at android.app.Activity.startActivity(Activity.java:3302)
06-22 21:01:50.625: E/AndroidRuntime(18120): at com.wks.calorieapp.activities.HomeActivity$OnGridActivitiesClicked.onItemClick(EActivity.java:89)
06-22 21:01:50.625: E/AndroidRuntime(18120): at android.widget.AdapterView.performItemClick(AdapterView.java:292)
06-22 21:01:50.625: E/AndroidRuntime(18120): at android.widget.AbsListView.performItemClick(AbsListView.java:1181)
06-22 21:01:50.625: E/AndroidRuntime(18120): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2709)
06-22 21:01:50.625: E/AndroidRuntime(18120): at android.widget.AbsListView$1.run(AbsListView.java:3464)
06-22 21:01:50.625: E/AndroidRuntime(18120): at android.os.Handler.handleCallback(Handler.java:605)
06-22 21:01:50.625: E/AndroidRuntime(18120): at android.os.Handler.dispatchMessage(Handler.java:92)
06-22 21:01:50.625: E/AndroidRuntime(18120): at android.os.Looper.loop(Looper.java:137)
06-22 21:01:50.625: E/AndroidRuntime(18120): at android.app.ActivityThread.main(ActivityThread.java:4511)
06-22 21:01:50.625: E/AndroidRuntime(18120): at java.lang.reflect.Method.invokeNative(Native Method)
06-22 21:01:50.625: E/AndroidRuntime(18120): at java.lang.reflect.Method.invoke(Method.java:511)
06-22 21:01:50.625: E/AndroidRuntime(18120): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
06-22 21:01:50.625: E/AndroidRuntime(18120): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
06-22 21:01:50.625: E/AndroidRuntime(18120): at dalvik.system.NativeStart.main(Native Method)