2013-11-15 20 views
1

我製作了一個使用LWUIT IO庫進行http請求的方法,並嘗試使用J2me庫。一切都在模擬器上正常工作,但當我厭倦了兩個不同的諾基亞手機,然後我收到異常。兩者都顯示了不同的例外。 者除外使用LWUIT IO和J2me庫進行http請求時出現異常

  1. 411長度所需
  2. 產生java.io.IOException:錯誤HTTP操作:在HTTP操作錯誤

這裏是我的代碼 -

private void startReq(String url) { 
    NetworkManager.getInstance().start(); 
    ConnectionRequest myRequest = new ConnectionRequest() { 
    protected void readResponse(InputStream input) throws IOException { 
      StringBuffer stringBuffer = new StringBuffer(); 
      int ch; 
      while ((ch = input.read()) != -1) { 
       stringBuffer.append((char) ch); 
      } 
      System.out.println("Response:"+stringBuffer.toString()); 

     } 
    }; 

    progress = new Progress("Please Wait ", myRequest,true); 
    progress.setDisposeOnCompletion(true); 


    myRequest.setUrl(url); 
    myRequest.setPost(true); 
    NetworkManager.getInstance().addToQueue(myRequest); 
    progress.show(); 

} 

回答

1

我有找到解決方案,這是與移動接入點有關的問題。我無法識別這個問題,因爲互聯網在瀏覽器中工作得很好。所以我不能猜測,原因可以是接入點。問題解決了,但我仍然不滿意,也感到驚訝,所有的應用程序如何能夠訪問互聯網服務,而不是我的Midlet。

Check this link to change access point settings

,如果有人知道這種行爲的原因親切清楚我的疑問。

相關問題