Try/Catch with if conditions in Java/Android -
i trying catch exception , not allow app force close. hence put try , catch blow:
try { string[] words = message.split(" "); strbuilder.setlength(0); numberstring = words[8]; if (numberstring.length() > 4) { numberstring = numberstring.substring((numberstring.length() - 4)); } if ((message.contains("return"))) { amountstring = words[0]; amountstring = amountstring.replace(",", ""); amountstring = getfilter(message); } else { (int = 12; < words.length; i++) { text = words[i]; strbuilder.append(text + " "); str = strbuilder.tostring(); } amountstring = words[1]; amountstring = amountstring.replace(",", ""); namestring = str; } log.e("value","= " + amountstring + namestring + numberstring); } catch (notfoundexception e) { log.e("error","value not fetched"); } }
i trying above code in loop...
but app still crashes , gives error in amountstring = getfilter(message); why happening?
do need insert try , catch before amount=getfilter(message);?
you catching notfoundexception
there may other exception happening in code execution crashing app. try catching exception
find going wrong.
Comments
Post a Comment