나는 첫 번째 시작 인 경우 변경 로그를 검색하고 표시하는 코드를 사용하고 있습니다. :)Android HttpGet이 Android 4.0에서 작동하지 않습니까?
이 안드로이드 2.3 이하에서 잘 작동하지만, 사용자 정의 ICS-ROM과 에뮬레이터에하려고 할 때, 실패 ...
분명히if(lastVersion < currentVersion) {
InputStream content = null;
try {
HttpGet httpGet = new HttpGet("http://dreamhawk.blinkenshell.org/changelog.txt");
httpGet.setHeader("Content-Type", "text/plain; charset=utf-8");
HttpClient httpclient = new DefaultHttpClient();
// Execute HTTP Get Request
HttpResponse response = httpclient.execute(httpGet);
content = response.getEntity().getContent();
} catch (Exception e) {
//handle the exception !
}
if(content == null) {
lastVersion = Prefs.getInt("firstRun", -1);
Toast.makeText(Main.this,
"Failed fetching changelog on first run, connected to Internet?",
Toast.LENGTH_SHORT).show();
} else {
BufferedReader r = new BufferedReader(new InputStreamReader(content));
StringBuilder total = new StringBuilder();
String line;
String NL = System.getProperty("line.separator");
try {
while ((line = r.readLine()) != null) {
total.append(line + NL);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String page = total.toString();
Dialog dialog = new Dialog(Main.this);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle(R.string.changelog);
dialog.setCanceledOnTouchOutside(true);
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setTextSize(13);
text.setText(page);
dialog.show();
}
}
, 내용이 null의 경우, 그리고 난 이유를 모르겠어 .. 그것이 다른 안드로이드 버전에서 작동하기 때문에, 나는 틀릴 수있는 것이 무엇인지 모르겠다. 그러나 나는 멍청하다. 아마 나는 나쁜 코드를 사용하고있을 것이다 ...
도움이 필요하십니까? :)
에뮬레이터가 인터넷에 액세스하기 위해 프록시를 설정해야합니까? –
아니요 : - \ – DreamHawk