Android的发布到Facebook的图像超时 [英] Android Post to Facebook image timeout

查看:261
本文介绍了Android的发布到Facebook的图像超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有简单的后期图像Facebook的实现:

I have simple post-image to Facebook implementation:

Bundle params = new Bundle();
params.putString("message", message);
params.putByteArray("picture", data);

String uploadResponse = mFacebook.request("me/photos", params, "POST");

这是在一个线程中执行。

This is executed in a Thread.

现在。是否有超时,因为当网络很慢Facebook的请求时,它是永恒的办法?

Now. Is there a way to "timeout" the Facebook request since when the network is slow it lasts forever?

感谢

推荐答案

看起来不像你可以超时在当前code中的要求。

Doesn't look like you can timeout the request in the current code.

的<一个href=\"https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/android/Facebook.java\"相对=nofollow> Facebook的对象调用的的OpenURL 的的<方法href=\"https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/android/Util.java\"相对=nofollow>的Util 类。
此方法使用 HttpURLConnection类类发出请求,并且它具有<一个href=\"http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URLConnection.html#setConnectTimeout%28int%29\"相对=nofollow> setConnectTimeout 方法,您可以使用超时请求,但Facebook的实施不会让你传递一个参数,也许因为这种方法是从Java 1.5版新他们想要的SDK为较低的版本。

The Facebook object calls the openUrl method of the Util class. This method uses the HttpURLConnection class to make the request, and it has the setConnectTimeout method which you can use to timeout the request, but the facebook implementation does not let you pass a parameter for it, maybe since this method is new from java version 1.5 and they wanted the SDK to work for lower versions.

如果您在1.5或更高版本上运行你的应用程序,那么你可以简单地修改code你有Facebook的SDK,包括超时。

If you run your application on 1.5 or higher then you can simply modify the code you have for the facebook SDK to include timeout.

这篇关于Android的发布到Facebook的图像超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆