以下のコードでjava.lang.StringIndexOutOfBoundsException: index=0 length=0エラーが引き続き発生するif (result.charAt(0) =='Y')
でヌル文字列をチェックする他の良い方法はありますif (result == null || result.isEmpty())
か? 何らかの理由で空文字列「結果」が取得されactivity.finish();
なかったか実行されず、次の if ステートメントが実行されましたか? 助けてください。
@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();
}