[問題] 連結網頁的方法
網路上GOOGLE的方法很多好像API更新後已停用
因此我到函示庫看新方法:http://developer.android.com/reference/java/net/HttpURLConnection.html
我用了
URL url = new URL("http://www.android.com/");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
try {
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
readStream(in);
finally {
urlConnection.disconnect();
}
}
他範例這一段 編譯有問題
因此我改為
try {
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
} catch (IOException e) {
e.printStackTrace()
}
但是這樣子會出現執行時會出現錯誤
InputStream in = new BufferedInputStream(urlConnection.getInputStream()<<這一行拿掉就可以
請問是為何?
還是連網頁的語法能用哪一個方法去時做會比較能夠理解
我的目標是傳值給PHP PHP再傳值回去給APP
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.115.226.154
※ 文章網址: https://www.ptt.cc/bbs/AndroidDev/M.1434567421.A.CB9.html
推
06/19 22:39, , 1F
06/19 22:39, 1F
→
06/19 22:39, , 2F
06/19 22:39, 2F
→
06/19 22:39, , 3F
06/19 22:39, 3F
AndroidDev 近期熱門文章
PTT數位生活區 即時熱門文章