我在清单文件中有这个意图:
<activity
android:name=".ProductStrategyActivity"
android:label="@string/product_strategy_header" />
当我尝试执行此操作时出现异常:
Intent myIntent = new Intent(LearnActivity.this, ProductStrategyActivity.class);
LearnActivity.this.startActivity(myIntent);
并且该类位于我的 src/com/app_name/content/ 目录中的一个包中。
问题可能是我需要在清单文件中指定该目录吗?
对不起,我在异常中犯了一个错误。这是堆栈跟踪:
04-27 02:07:23.221: E/AndroidRuntime(1234): FATAL EXCEPTION: main
04-27 02:07:23.221: E/AndroidRuntime(1234): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.problemio/com.problemio.content.ProductStrategyActivity}; have you declared this activity in your AndroidManifest.xml?
04-27 02:07:23.221: E/AndroidRuntime(1234): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1508)
04-27 02:07:23.221: E/AndroidRuntime(1234): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
04-27 02:07:23.221: E/AndroidRuntime(1234): at android.app.Activity.startActivityForResult(Activity.java:3190)
04-27 02:07:23.221: E/AndroidRuntime(1234): at android.app.Activity.startActivity(Activity.java:3297)
04-27 02:07:23.221: E/AndroidRuntime(1234): at com.problemio.LearnActivity$3.onClick(LearnActivity.java:113)
04-27 02:07:23.221: E/AndroidRuntime(1234): at android.view.View.performClick(View.java:3511)
04-27 02:07:23.221: E/AndroidRuntime(1234): at android.view.View$PerformClick.run(View.java:14105)
04-27 02:07:23.221: E/AndroidRuntime(1234): at android.os.Handler.handleCallback(Handler.java:605)
04-27 02:07:23.221: E/AndroidRuntime(1234): at android.os.Handler.dispatchMessage(Handler.java:92)
04-27 02:07:23.221: E/AndroidRuntime(1234): at android.os.Looper.loop(Looper.java:137)
04-27 02:07:23.221: E/AndroidRuntime(1234): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-27 02:07:23.221: E/AndroidRuntime(1234): at java.lang.reflect.Method.invokeNative(Native Method)
04-27 02:07:23.221: E/AndroidRuntime(1234): at java.lang.reflect.Method.invoke(Method.java:511)
04-27 02:07:23.221: E/AndroidRuntime(1234): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-27 02:07:23.221: E/AndroidRuntime(1234): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-27 02:07:23.221: E/AndroidRuntime(1234): at dalvik.system.NativeStart.main(Native Method)
那行 LearnActivity.java:113 是我告诉当前意图转到新的意图的地方。
谢谢!