Still getting java.lang.StringIndexOutOfBoundsException: index=0 length=0 error in the code below at if (result.charAt(0) =='Y')
Is there any other better way to check for null strings at if (result == null || result.isEmpty()) ? For some reason the null string “result” was not picked up or activity.finish(); did not execute and the next if statement was executed? Any help please.
@Override
protected void onPostExecute(String result) {
//check if result null or empty
if (result == null || result.isEmpty()) {
Toast.makeText(context, "Could Not Check For Updates, Please Try Again. Closing Application.", Toast.LENGTH_LONG).show();
activity.finish();
}
//update available
if (result.charAt(0) =='Y') {
UpdateAlert();
}
//no update available
else if (result.charAt(0) =='N') {
Toast.makeText(context, "No Updates Available", Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(context, "Could Not Check For Updates, Please Try Again. Closing Application : " + result, Toast.LENGTH_LONG).show();
activity.finish();
}
1 Answer