android上传照片到facebook非法线程异常

发布于 2024-12-07 18:39:40 字数 2764 浏览 0 评论 0原文

在我的应用程序中,我向用户提供使用 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 技术交流群。

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

发布评论

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

评论(1

别忘他 2024-12-14 18:39:40

尝试:

Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), SELECT_PICTURE);

此处提取

try:

Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), SELECT_PICTURE);

extracted from here

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