android - 对于 Android,如何设置 Cloud Endpoint 请求的最长期限?

标签 android google-app-engine google-cloud-endpoints

当从 Android 应用向 App-Engine 服务发出 ClientEndpoint API 请求时,如何为 execute() 操作设置截止日期/超时?

我正在寻找类似的东西:

Foo foo = endpoint.getSomething(id) .setDeadline(2000/*ms*/) .execute();

最佳答案

构建端点时,在 HttpRequestInitializer 中指定连接和读取超时。例如,在本例中分别为 20 秒和 10 秒。

SomeEndpoint.Builder endpointBuilder = new SomeEndpoint.Builder(
    AndroidHttp.newCompatibleTransport(),
    new JacksonFactory(), new HttpRequestInitializer() {
        public void initialize(HttpRequest httpRequest) {
            httpRequest.setConnectTimeout(20 * 1000);
            httpRequest.setReadTimeout(10 * 1000);
        }
    });

关于android - 对于 Android,如何设置 Cloud Endpoint 请求的最长期限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20391173/

相关文章:

java - 部署时我的一种云端点方法出现 500 Internal Server Error

java - 从 Cron Job App Engine 调用端点类 - Java

android - Android Studio 中的自动填充功能参数

android - leftDrawable 和 rightDrawable 的单选按钮空间

android - EditText 提示在 inputType ="textpassword"时显示额外的空格

python - 在 Django 模板中迭代 Expando 的动态属性

jsp - 获取 IllegalStateException : No such servlet: jsp when accessing deployed Spring application to Google App Engine

python - 运行 Google App Engine Python 的本地数据存储是否有任何限制?

android: 从 Broadcastreceiver 调用函数: 无法启动接收器 ... java.lang.ClassCastException: android.app.ReceiveRestrictedContext

google-app-engine - 使用谷歌应用引擎、云存储、数据存储的应用程序如何在中国运营?