【问题标题】:onActivityResult fc when using SurfaceView on Android在 Android 上使用 SurfaceView 时的 onActivityResult fc
【发布时间】:2010-09-04 23:43:52
【问题描述】:

当使用 SurfaceView 作为内容视图的活动调用 startActivityForResult(...) 并且已启动的活动调用 finish() 时,我的应用程序 fc

如果我将内容视图更改为 SurfaceView 以外的其他内容,则不会发生这种情况。

这将是请求的 logcat:

09-05 00:17:18.926:错误/AndroidRuntime(339):未捕获的处理程序:线程主因未捕获的异常而退出 09-05 00:17:18.937: 错误/AndroidRuntime(339): java.lang.IllegalThreadStateException: 线程已经启动。 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 java.lang.Thread.start(Thread.java:1322) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 fi.mikuz.soundboards.GraphicalSoundboardEditor$DrawingPanel.surfaceCreated(GraphicalSoundboardEditor.java:426) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 android.view.SurfaceView.updateWindow(SurfaceView.java:454) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:189) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 android.view.View.dispatchWindowVisibilityChanged(View.java:3782) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:692) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:692) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:692) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 android.view.ViewRoot.performTraversals(ViewRoot.java:706) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 android.view.ViewRoot.handleMessage(ViewRoot.java:1633) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 android.os.Handler.dispatchMessage(Handler.java:99) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 android.os.Looper.loop(Looper.java:123) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 android.app.ActivityThread.main(ActivityThread.java:4363) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 java.lang.reflect.Method.invokeNative(Native Method) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 java.lang.reflect.Method.invoke(Method.java:521) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 09-05 00:17:18.937: 错误/AndroidRuntime(339): 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 09-05 00:17:18.937: 错误/AndroidRuntime(339): at dalvik.system.NativeStart.main(Native Method)

【问题讨论】:

  • 在 Eclipse 中使用 adb logcat、DDMS 或 DDMS 透视图检查 LogCat 并查看与“fc”相关联的堆栈跟踪。

标签: android surfaceview


【解决方案1】:
09-05 00:17:18.926: ERROR/AndroidRuntime(339): Uncaught handler: thread main exiting due to uncaught exception
09-05 00:17:18.937: ERROR/AndroidRuntime(339): java.lang.IllegalThreadStateException: Thread already started.
09-05 00:17:18.937: ERROR/AndroidRuntime(339): at java.lang.Thread.start(Thread.java:1322)
09-05 00:17:18.937: ERROR/AndroidRuntime(339): at fi.mikuz.soundboards.GraphicalSoundboardEditor$DrawingPanel.surfaceCreated(GraphicalSoundboardEditor.java:426)

修复你的代码,这样你就不会启动一个已经启动的线程,这个异常就会消失。

【讨论】:

  • 是的,我正试图弄清楚如何暂停/停止我的线程,但我得到的只是错误。
猜你喜欢
  • 1970-01-01
  • 2021-10-05
  • 1970-01-01
  • 1970-01-01
  • 2014-03-03
  • 1970-01-01
  • 2011-03-15
  • 2012-12-22
  • 2013-04-01
相关资源
最近更新 更多