ActivityNotFound异常异常

发布于 2024-12-01 00:05:24 字数 2970 浏览 0 评论 0原文

我在一个活动中收到此错误,这是没有意义的,因为我可以从另一个活动转到日历活动,所以我知道我在清单中正确声明了它

<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();

我可以从活动 ACalendar 活动就好,然后 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南七夏 2024-12-08 00:05:24

导入正确的包。我猜您正在 Events 类中导入类似 java.util.Calendar 的内容。

如果由于某种原因,您需要两个 Calendar 类(您编写的一个和 java.util 一个),则必须输入完整路径...例如:

Intent ok = new Intent(Events.this, your.pkg.example.Calendar.class);

Import the correct package. I guess you are importing something like java.util.Calendar in your Events class.

If, for some reason, you need both Calendar classes (the one you wrote and the java.util one), you must put the complete path... for instance:

Intent ok = new Intent(Events.this, your.pkg.example.Calendar.class);
傲世九天 2024-12-08 00:05:24

当您调用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().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文