0

私はその中でPOSTアクションを実行するアプリケーションを作っています。以下に表示されますBlackBerryでPOSTを実行するためにインターネットにアクセスするさまざまな方法

//private boolean x = false; 
url = "http://domain.com/login"; 
InputStream inputStream = null; 
ConnectionFactory connFact = new ConnectionFactory(); 
ConnectionDescriptor connDesc; 
connDesc = connFact.getConnection(url); 
if (connDesc != null) 
{ 
    HttpConnection httpConn; 
    httpConn = (HttpConnection)connDesc.getConnection(); 
    httpConn.setRequestMethod(HttpConnection.POST); 
    httpConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 

    URLEncodedPostData encPostData = new URLEncodedPostData("UTF-8", false); 

    encPostData.append("username",username); 
    encPostData.append("password",password); 

    byte[] postData = encPostData.toString().getBytes("UTF-8"); 
    httpConn.setRequestProperty("Content-Length", String.valueOf(postData.length)); 

    httpConn.openOutputStream().write(encPostData.getBytes()); 

    try 
    { 
     int Response = httpConn.getResponseCode(); 
     System.out.println("Response Code = "+Response+httpConn.getResponseCode()); 
     if (Response == 200) 
     { 
      System.out.println("Response Code = "+Response+httpConn.getResponseCode()); 
      inputStream = httpConn.openInputStream(); 
      byte[] responseData = new byte[10000]; 
      int length = 0; 
      StringBuffer rawResponse = new StringBuffer(10000); 
      while (-1 != (length = inputStream.read(responseData))) 
      { 
       rawResponse.append(new String(responseData, 0, length)); 
      } 
      replyMessage = rawResponse.toString(); 
      key = replyMessage.substring(12, replyMessage.length()-2); 
     } 
     else if(Response == 500) 
     { 
      Dialog.alert("User Details Incorrect"); 
     } 
     else 
     { 
      System.out.println(Response); 
     } 
    } 
    catch (IOException e) 
    { 
     Dialog.alert("Connection not established"); 
    } 
} 
else 
{ 
    Dialog.alert("Connection not established"); 
} 
return key; 

私は現在、このサービスがどのような種類のサービスになるのか不思議です。 私は

は、ネットワークが利用できる最初の特定のn後でネットワークを選択するためにとにかくそこ..ですあまりに あるいは他の方法で回避。..何のGPRS/3Gが存在しない場合、自分のアプリケーションの仕事をしたいが、WiFi接続を持っていますコミュニケーション。

はありがとう、私はこの点で任意のヘルプをお願い

..

答えて

関連する問題