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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -