실제 장치에서 GPRS (모바일 네트워크)를 통해 URL의 HttpConnection을 만들려고했으나 데이터를 반환하지 않지만 코드가 잘 작동하는 동일한 코드가 와이어리스를 통해 잘 작동합니다. 시뮬레이터 내 코드GPRS (모바일 네트워크)를 통한 HttpConnection
public static String getHttpUTFResponse(String url) {
HttpConnection connection = null;
byte responseData[] = null;
try {
connection = (HttpConnection) new ConnectionFactory()
.getConnection(url).getConnection();
int len = (int) connection.getLength();
System.out.println(len);
if (len != -1) {
responseData = new byte[len];
DataInputStream dis;
dis = new DataInputStream(connection.openInputStream());
dis.readFully(responseData);
dis.close();
}
} catch (IOException e) {
System.out.println("Connection Error");
} finally {
if (connection != null) {
try {
connection.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
connection = null;
}
}
if (responseData != null) {
try {
return new String(responseData,"UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
주 : 장치 브라우저가 잘 작동하고 BB 서비스는 나는이 대답에 내 의견을 이동하고 하나
당신이 코드를 디버깅 있나요? 예외가 있습니까? 줄 번호는 무엇입니까? – Vimal
이 줄에서 멈 춥니 다. int len = (int) connection.getLength(); 그 후 len은 (-1)을 반환하고 예외는 없습니다 – JustMe
** BES **에 대해서는 deviceside = false, connectionUID = "'** BIS ** 및 " "; deviceside = false"'접미사가 있습니까? * 연결 URL에? – Vimal