从我的自定义主屏幕启动时相机和地图崩溃

发布于 2024-12-22 00:24:18 字数 3895 浏览 3 评论 0原文

我创建了一个自定义主屏幕。 这是我在单击时启动应用程序的代码:

mainIntent = packageManager.getLaunchIntentForPackage(strPackageName);
if(mainIntent!=null)
{
    mainIntent = mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
                           .addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    startActivity(mainIntent);
}

一切正常,除了启动相机或 Google 地图时出现异常:

E/AndroidRuntime(845): FATAL EXCEPTION: main
E/AndroidRuntime(845): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.camera/com.android.internal.app.ResolverActivity}; have you declared this activity in your AndroidManifest.xml?
E/AndroidRuntime(845):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1536)
E/AndroidRuntime(845):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1510)
E/AndroidRuntime(845):  at android.app.Activity.startActivityForResult(Activity.java:2858)
E/AndroidRuntime(845):  at android.app.Activity.startActivity(Activity.java:2964)
E/AndroidRuntime(845):  at com.gears42.surelock.ApplicationLauncher.onItemClick(ApplicationLauncher.java:34)
E/AndroidRuntime(845):  at android.widget.AdapterView.performItemClick(AdapterView.java:284)
E/AndroidRuntime(845):  at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
E/AndroidRuntime(845):  at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime(845):  at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(845):  at android.os.Looper.loop(Looper.java:143)
E/AndroidRuntime(845):  at android.app.ActivityThread.main(ActivityThread.java:4914)
E/AndroidRuntime(845):  at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(845):  at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(845):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
E/AndroidRuntime(845):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
E/AndroidRuntime(845):  at dalvik.system.NativeStart.main(Native Method)


E/AndroidRuntime(872): FATAL EXCEPTION: main
E/AndroidRuntime(872): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.google.android.apps.maps/com.android.internal.app.ResolverActivity}; have you declared this activity in your AndroidManifest.xml?
E/AndroidRuntime(872):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1536)
E/AndroidRuntime(872):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1510)
E/AndroidRuntime(872):  at android.app.Activity.startActivityForResult(Activity.java:2858)
E/AndroidRuntime(872):  at android.app.Activity.startActivity(Activity.java:2964)
E/AndroidRuntime(872):  at com.gears42.surelock.ApplicationLauncher.onItemClick(ApplicationLauncher.java:34)
E/AndroidRuntime(872):  at android.widget.AdapterView.performItemClick(AdapterView.java:284)
E/AndroidRuntime(872):  at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
E/AndroidRuntime(872):  at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime(872):  at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(872):  at android.os.Looper.loop(Looper.java:143)
E/AndroidRuntime(872):  at android.app.ActivityThread.main(ActivityThread.java:4914)
E/AndroidRuntime(872):  at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(872):  at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(872):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
E/AndroidRuntime(872):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
E/AndroidRuntime(872):  at dalvik.system.NativeStart.main(Native Method)

我正在使用 2.2.1 HTC Wildfire(在 Android 3.1 Samsung Galaxy Tab 上同样可以完美运行)

任何建议/解决方法??

I've created a custom home screen.
This is my code to launch an application when clicked:

mainIntent = packageManager.getLaunchIntentForPackage(strPackageName);
if(mainIntent!=null)
{
    mainIntent = mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
                           .addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    startActivity(mainIntent);
}

Everything works fine except that while launching Camera or Google Maps i get an exception:

E/AndroidRuntime(845): FATAL EXCEPTION: main
E/AndroidRuntime(845): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.camera/com.android.internal.app.ResolverActivity}; have you declared this activity in your AndroidManifest.xml?
E/AndroidRuntime(845):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1536)
E/AndroidRuntime(845):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1510)
E/AndroidRuntime(845):  at android.app.Activity.startActivityForResult(Activity.java:2858)
E/AndroidRuntime(845):  at android.app.Activity.startActivity(Activity.java:2964)
E/AndroidRuntime(845):  at com.gears42.surelock.ApplicationLauncher.onItemClick(ApplicationLauncher.java:34)
E/AndroidRuntime(845):  at android.widget.AdapterView.performItemClick(AdapterView.java:284)
E/AndroidRuntime(845):  at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
E/AndroidRuntime(845):  at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime(845):  at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(845):  at android.os.Looper.loop(Looper.java:143)
E/AndroidRuntime(845):  at android.app.ActivityThread.main(ActivityThread.java:4914)
E/AndroidRuntime(845):  at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(845):  at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(845):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
E/AndroidRuntime(845):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
E/AndroidRuntime(845):  at dalvik.system.NativeStart.main(Native Method)


E/AndroidRuntime(872): FATAL EXCEPTION: main
E/AndroidRuntime(872): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.google.android.apps.maps/com.android.internal.app.ResolverActivity}; have you declared this activity in your AndroidManifest.xml?
E/AndroidRuntime(872):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1536)
E/AndroidRuntime(872):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1510)
E/AndroidRuntime(872):  at android.app.Activity.startActivityForResult(Activity.java:2858)
E/AndroidRuntime(872):  at android.app.Activity.startActivity(Activity.java:2964)
E/AndroidRuntime(872):  at com.gears42.surelock.ApplicationLauncher.onItemClick(ApplicationLauncher.java:34)
E/AndroidRuntime(872):  at android.widget.AdapterView.performItemClick(AdapterView.java:284)
E/AndroidRuntime(872):  at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
E/AndroidRuntime(872):  at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime(872):  at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(872):  at android.os.Looper.loop(Looper.java:143)
E/AndroidRuntime(872):  at android.app.ActivityThread.main(ActivityThread.java:4914)
E/AndroidRuntime(872):  at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(872):  at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(872):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
E/AndroidRuntime(872):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
E/AndroidRuntime(872):  at dalvik.system.NativeStart.main(Native Method)

I'm using 2.2.1 HTC Wildfire (The same works perfectly on Android 3.1 Samsung Galaxy Tab)

Any suggestions / workarounds ??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

爱你不解释 2024-12-29 00:24:18

这部分看起来很奇怪:

E/AndroidRuntime(872): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.google.android.apps.maps/com.android.internal.app.ResolverActivity}; have you declared this activity in your AndroidManifest.xml?

您是否尝试过将其添加到清单中?

this part looks strange:

E/AndroidRuntime(872): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.google.android.apps.maps/com.android.internal.app.ResolverActivity}; have you declared this activity in your AndroidManifest.xml?

Have you tried adding that to your manifest?

就此别过 2024-12-29 00:24:18

使用 Intent Intend = new Intend(new ComponentName(packakeName, className)); 代替

use Intent intend = new Intend(new ComponentName(packakeName, className)); instead

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