android上传照片到facebook非法线程异常
在我的应用程序中,我向用户提供使用 action_send 意图进行共享的选项。 在上传到 Facebook 的过程中,我的应用程序崩溃了,但照片上传成功。 这是我的代码和 logcat。你有什么建议?
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.fromFile(file);
sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
sharingIntent.setType("image/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
getContext().startActivity(Intent.createChooser(sharingIntent, "Share image using"));
堆栈跟踪:
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): FATAL EXCEPTION: main
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): java.lang.IllegalThreadStateException: Thread already started.
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at java.lang.Thread.start(Thread.java:1322)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at tomer.idunku3.GameView$1.surfaceCreated(GameView.java:103)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.SurfaceView.updateWindow(SurfaceView.java:532)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:206)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.View.dispatchWindowVisibilityChanged(View.java:3891)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:719)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:719)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:719)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.ViewRoot.performTraversals(ViewRoot.java:744)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.os.Handler.dispatchMessage(Handler.java:99)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.os.Looper.loop(Looper.java:123)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at java.lang.reflect.Method.invokeNative(Native Method)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at java.lang.reflect.Method.invoke(Method.java:521)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at dalvik.system.NativeStart.main(Native Method)
in my app i give the user otion to share using action_send intent.
during the upload to facebook my app crashes but the photo uploading succeeds.
this is my code and the logcat. what do you suggest?
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.fromFile(file);
sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
sharingIntent.setType("image/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
getContext().startActivity(Intent.createChooser(sharingIntent, "Share image using"));
Stacktrace:
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): FATAL EXCEPTION: main
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): java.lang.IllegalThreadStateException: Thread already started.
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at java.lang.Thread.start(Thread.java:1322)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at tomer.idunku3.GameView$1.surfaceCreated(GameView.java:103)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.SurfaceView.updateWindow(SurfaceView.java:532)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:206)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.View.dispatchWindowVisibilityChanged(View.java:3891)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:719)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:719)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:719)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.ViewRoot.performTraversals(ViewRoot.java:744)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.os.Handler.dispatchMessage(Handler.java:99)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.os.Looper.loop(Looper.java:123)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at java.lang.reflect.Method.invokeNative(Native Method)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at java.lang.reflect.Method.invoke(Method.java:521)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-01 23:06:59.649: ERROR/AndroidRuntime(7273): at dalvik.system.NativeStart.main(Native Method)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试:
从此处提取
try:
extracted from here