ActivityNotFound异常异常
我在一个活动中收到此错误,这是没有意义的,因为我可以从另一个活动转到日历活动,所以我知道我在清单中正确声明了它
<activity android:name=".Calendar" android:label="Calendar"/>
意图在对话框选择中
Intent ok = new Intent(Events.this,Calendar.class);
ok.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(ok); //ActivityNotFoundException
finish();
我可以从活动 A
到 Calendar
活动就好,然后 Calendar
活动可以访问我的 Events
活动,但我不能离开我的事件
到日历
活动?
这是为什么?
编辑:更新有错误
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): FATAL EXCEPTION: main
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.app.notifyme/java.util.Calendar}; have you declared this activity in your AndroidManifest.xml?
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.Activity.startActivityForResult(Activity.java:2827)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.Activity.startActivity(Activity.java:2933)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at com.app.notifyme.Events$12.onClick(Events.java:318)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:873)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.widget.ListView.performItemClick(ListView.java:3513)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1849)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.os.Handler.handleCallback(Handler.java:587)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.os.Handler.dispatchMessage(Handler.java:92)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.os.Looper.loop(Looper.java:123)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.ActivityThread.main(ActivityThread.java:3839)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at java.lang.reflect.Method.invokeNative(Native Method)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at java.lang.reflect.Method.invoke(Method.java:507)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at dalvik.system.NativeStart.main(Native Method)
I am getting this error in my one activity and it is making no sense because I can go to the Calendar
activity from another activity so I know i declared it correctly in the manifest
<activity android:name=".Calendar" android:label="Calendar"/>
Intent is in a Dialog selection
Intent ok = new Intent(Events.this,Calendar.class);
ok.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(ok); //ActivityNotFoundException
finish();
I can from activity A
to the Calendar
activity just fine then the Calendar
activity has access to my Events
activity but I cant go from my Events
to the Calendar
activity??
Ideas as to why this is?
EDIT: Update with error
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): FATAL EXCEPTION: main
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.app.notifyme/java.util.Calendar}; have you declared this activity in your AndroidManifest.xml?
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.Activity.startActivityForResult(Activity.java:2827)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.Activity.startActivity(Activity.java:2933)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at com.app.notifyme.Events$12.onClick(Events.java:318)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:873)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.widget.ListView.performItemClick(ListView.java:3513)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1849)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.os.Handler.handleCallback(Handler.java:587)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.os.Handler.dispatchMessage(Handler.java:92)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.os.Looper.loop(Looper.java:123)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.ActivityThread.main(ActivityThread.java:3839)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at java.lang.reflect.Method.invokeNative(Native Method)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at java.lang.reflect.Method.invoke(Method.java:507)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at dalvik.system.NativeStart.main(Native Method)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
导入正确的包。我猜您正在
Events
类中导入类似java.util.Calendar
的内容。如果由于某种原因,您需要两个
Calendar
类(您编写的一个和java.util
一个),则必须输入完整路径...例如:Import the correct package. I guess you are importing something like
java.util.Calendar
in yourEvents
class.If, for some reason, you need both
Calendar
classes (the one you wrote and thejava.util
one), you must put the complete path... for instance:当您调用
finish()
时,系统实际上会从堆栈中删除该活动。这将不允许您返回该活动。
我建议您仔细阅读Activity 生命周期文档。
它应该可以帮助您找出问题所在。 :)
编辑:
您也不应该需要该标志。只需开始活动,系统就会处理剩下的事情。
您也无权从一项活动访问另一项活动。每个活动都是一个独立的单元,不应尝试访问其他活动。
如果您需要在活动之间传递数据,请在单独的类中使用静态类/变量,或使用
Intent.putExtra()
传递它。When you call
finish()
the system actually removes the activity from the stack.This disallows you from going back to that activity.
I suggest you carefully read the Activity Lifecycle Documentation.
It should help you figure out your problem. :)
EDIT:
You should also not need that flag. Just start the activity, the system will take care of the rest.
You also do not have access to one activity from another activity. Each activity is a standalone unit that should not attempt to access other activities.
If you need to pass data between activities, use a static class/variable in a seperate class, or pass it using
Intent.putExtra()
.