从我的自定义主屏幕启动时相机和地图崩溃
我创建了一个自定义主屏幕。 这是我在单击时启动应用程序的代码:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这部分看起来很奇怪:
您是否尝试过将其添加到清单中?
this part looks strange:
Have you tried adding that to your manifest?
使用
Intent Intend = new Intend(new ComponentName(packakeName, className));
代替use
Intent intend = new Intend(new ComponentName(packakeName, className));
instead