2012-05-16 23 views
0

我正在使用Eclipse來(嘗試)構建Android客戶端以獲得重用我使用GAE和GWT開發的restlet服務。Android使用restlet與GAE通信面臨的挑戰

我的服務就是在

http://127.0.0.1:8888/abc/audits 

運行我可以直接去這個網址進行測試,並通過我的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(); 
+0

而不是127.0.0.1我會使用10.0.2.2;) – rciovati

回答

0

它出現的問題是安卓模擬器無法連接到任何127.0.0.1或10.0.2.2。解決方案是使用您的PC的IP地址。

0

我可以通過Android/Restlet使用10.0.2.2而不是本地主機從Android連接到本地Google App Engine。