无法更新连接到Android项目后端的GAE项目中的实体

时间:2014-12-18 08:38:41

标签: android google-app-engine jpa

我是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上部署任何内容。

1 个答案:

答案 0 :(得分:0)

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

相关问题