【问题标题】:Challenge with Android communicating to GAE using restletAndroid 使用 restlet 与 GAE 通信的挑战
【发布时间】:2012-05-24 09:25:41
【问题描述】:

我正在使用 Eclipse(尝试)构建一个 Android 客户端,以重用我使用 GAE 和 GWT 开发的 restlet 服务。

我的服务正在运行

    http://127.0.0.1:8888/abc/audits  

我可以通过直接访问此 url 并使用我的 GWT 客户端进行测试——两​​者都可以。

但是,以下代码返回通信错误

    private AuditsResource resource;
    private Audits audits;

    ClientResource cr = new ClientResource("http://127.0.0.1:8888/abc/audits");
    resource = cr.wrap(AuditsResource.class);
    try {
    // Get the remote contact
     audits = resource.retrieve();
    // The task is over, let the parent conclude.
    handler.sendEmptyMessage(0);
    } catch (Exception e) {
        Message msg = Message.obtain(handler, 2);
        Bundle data = new Bundle();
        data.putString("msg", "Cannot get the contact due to: "
            + e.getMessage());
        msg.setData(data);
        handler.sendMessage(msg);
    }

我不知道下一步该往哪里看。我已经检测了 AuditsResource 的服务器实现,它从未被(Android 应用程序)触及。

AuditsResource 类有一个方法,暂时保持简单

    @Get
    public Audits retrieve();

【问题讨论】:

  • 而不是 127.0.0.1 我会使用 10.0.2.2 ;)

标签: android google-app-engine gwt restlet


【解决方案1】:

问题似乎是 Andriod 模拟器无法连接到 127.0.0.1 或 10.0.2.2。解决方案是使用您 PC 的 IP 地址。

【讨论】:

    【解决方案2】:

    我能够使用 10.0.2.2 而不是 localhost 通过 Android/Restlet 从 Android 连接到我的本地 Google App Engine。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-01
      • 2014-08-25
      相关资源
      最近更新 更多