3
我完全絕望,這就是爲什麼我要求你幫忙。我有一個Android應用程序下面的代碼:Android上的HTTP請求
public void OnButtonClick(View view) throws ClientProtocolException, IOException, Exception
{
URL yahoo = new URL("http://privyrobsi.sk/brigades/getBrigades.json");
URLConnection yc = yahoo.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
EditText ET = (EditText) findViewById(R.id.editText2);
while ((inputLine = in.readLine()) != null) ET.setText(ET.getText()+inputLine);
in.close();
}
我得到這個代碼here,我只是修改了一些。 當我嘗試將代碼作爲獨立的Java應用程序運行時,它可以正常工作。但是當我嘗試在android中使用它時,模擬器說不幸的是,應用程序停止了。 我保存了LogCat的日誌here。 我的清單文件中也有使用權限android:name =「android.permission.INTERNET」。