I am using a code that retrieves and shows the Changelog if its the first startup, simple as that :).
This works well on Android 2.3 and lower, but when trying on Custom ICS-ROM and on Emulator, it fails...
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();
}
}
Apparently, content is null, and i don't know why.. Because it's working on other android-versions, i don't know what could possibly be wrong... But being the noob that i am, i am probably using some bad codes...
Care to help? :)