【问题标题】:Not able to update an entity in GAE project which is linked backend to an Android project无法更新将后端链接到 Android 项目的 GAE 项目中的实体
【发布时间】:2014-12-18 08:38:40
【问题描述】:

我是 Android 和 GAE 的新手,正在尝试创建示例应用。我能够实现 insertEntity 和 listEntity。一切正常。但是当我尝试使用 updateEntity 更新实体时,它不起作用。 android 项目甚至不调用后端 gae。我确定我在这里遗漏了一些非常明显的东西,但根本无法弄清楚。

这是我调用更新实体的android应用代码

private class ParentObjectUpdateTask extends AsyncTask<ParentObject, Void, UpdateParentObject> {

    /**
     * Calls appropriate CloudEndpoint to update
     *
     * @param params
     *            the object to update.
     */
    @Override
    protected UpdateParentObject doInBackground(ParentObject... params) {
        ParentObject parentObj = params[0];

        Parentobjectendpoint.Builder builder = new Parentobjectendpoint.Builder(
                AndroidHttp.newCompatibleTransport(), new JacksonFactory(),
                null);

        builder = CloudEndpointUtils.updateBuilder(builder);

        Parentobjectendpoint endpoint = builder.build();

        UpdateParentObject updatedObj;

        try {
            updatedObj = endpoint.updateParentObject(parentObj);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            updatedObj = null;
        }

        return updatedObj;
    }

    @Override
    protected void onPostExecute(UpdateParentObject result) {
        // TODO Auto-generated method stub
        super.onPostExecute(result);
    }
}

HttpRequestInitializer 呢?我需要以某种方式在这里添加 PUT 方法吗?

只是为了缩小范围,我正在使用 Eclipse 在本地开发环境中工作,并没有在 GAE 上部署任何内容。

【问题讨论】:

    标签: android google-app-engine jpa


    【解决方案1】:

    updatedObj = endpoint.updateParentObject(parentObj) 行更改为 updatedObj = endpoint.updateParentObject(parentObj).execute(); 以执行 Cloud Endpoint 方法。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多