我做了一個應用程序,需要互聯網連接,以便我可以在我的應用程序中顯示一些數據。J2ME應用程序無法連接到互聯網在諾基亞c1-01
但是,當我在諾基亞c1-01測試我的應用程序時,它無法從我的服務器獲取數據,同時如果我在任何其他設備上檢查我的應用程序,他們很容易與互聯網連接,我可以看到我的應用程序。
這裏是我的代碼:
HttpConnection httpConn = null;
InputStream is = null;
OutputStream os = null;
StringBuffer sb = new StringBuffer();
try {
// Open an HTTP Connection object
httpConn = (HttpConnection) Connector.open(url);
// Setup HTTP Request to POST
httpConn.setRequestMethod(HttpConnection.POST);
httpConn.setRequestProperty("User-Agent",
"Profile/MIDP-2.0 Confirguration/CLDC-1.1");
httpConn.setRequestProperty("Accept_Language", "en-US");
//Content-Type is must to pass parameters in POST Request
httpConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
os = httpConn.openOutputStream();
os.write(params.getBytes());
/**Caution: os.flush() is controversial. It may create unexpected behavior
on certain mobile devices. Try it out for your mobile device **/
//os.flush();
// Read Response from the Server
//StringBuffer sb = new StringBuffer();
is = httpConn.openDataInputStream();
int chr;
while ((chr = is.read()) != -1) {
sb.append((char) chr);
}
} finally {
if (is != null) {
is.close();
}
if (os != null) {
os.close();
}
if (httpConn != null) {
httpConn.close();
}
}
我有我的代碼更改,以便它可以在我的諾基亞C1-01運行?
非常感謝您的回答。但我使用下面顯示的代碼通過php從服務器獲取數據:<?php include('config.inc.php'); $ sql = mysql_query(「select * from tb_name」); while($ data = mysql_fetch_assoc($ sql)){echo $ data ['field1]; }?>那麼你能告訴我什麼我必須添加在我的PHP頁面? – dhrut