android - java.lang.StackOverflowError causing problems in my app -


i having problem app, cannot figure out problem is. on ics app works, on 2.x has problems. believe has loop still bit confused.

developer console throws @ me error report:

exception class > java.lang.stackoverflowerror source method > matrix.setscale() 

this code causing problem...

private void shiftloop7() {     if (d7 != doy && d7 < 366)     {         d7 = d7 + 8;         shiftloop7();     }     else if(d7 == doy)     {          if (hour >= 0 && hour < 8)         {             shift.settext("c");             shift.settextappearance(getapplicationcontext(), r.style.cshift);              shiftimage.setimageresource(r.drawable.c);             timetill.settext("till 7:45 am");              dayshift.settext("a shift");             day1.setbackgroundresource(r.color.a);             day2.setbackgroundresource(r.color.a);             day3.setbackgroundresource(r.color.a);             day4.setbackgroundresource(r.color.a);              nightshift.settext("c shift");             night1.setbackgroundresource(r.color.c);             night2.setbackgroundresource(r.color.c);             night3.setbackgroundresource(r.color.c);             night4.setbackgroundresource(r.color.c);         }         else if (hour >= 8 && hour < 17)         {             shift.settext("a");             shift.settextappearance(getapplicationcontext(), r.style.ashift);              shiftimage.setimageresource(r.drawable.a);             timetill.settext("till 4:45 pm");              dayshift.settext("a shift");             day1.setbackgroundresource(r.color.a);             day2.setbackgroundresource(r.color.a);             day3.setbackgroundresource(r.color.a);             day4.setbackgroundresource(r.color.a);              nightshift.settext("c shift");             night1.setbackgroundresource(r.color.c);             night2.setbackgroundresource(r.color.c);             night3.setbackgroundresource(r.color.c);             night4.setbackgroundresource(r.color.c);         }         else         {             shift.settext("c");             shift.settextappearance(getapplicationcontext(), r.style.cshift);              shiftimage.setimageresource(r.drawable.c);             timetill.settext("till 7:45 am");              dayshift.settext("a shift");             day1.setbackgroundresource(r.color.a);             day2.setbackgroundresource(r.color.a);             day3.setbackgroundresource(r.color.a);             day4.setbackgroundresource(r.color.a);              nightshift.settext("c shift");             night1.setbackgroundresource(r.color.c);             night2.setbackgroundresource(r.color.c);             night3.setbackgroundresource(r.color.c);             night4.setbackgroundresource(r.color.c);         }     }     else     {         shiftloop8();     } } 

a common cause of stack overflow large number of recursive calls - either due bug causing infinite recursion, or code structured have deep recursion.

in case, stack overflow may caused fact code has potential large depth of recursive calls. restructure recursive calls while loops? example, instead of:

if (d7 != doy && d7 < 366) {     d7 = d7 + 8;     shiftloop7(); } 

could following:

while (d7 != doy && d7 < 366) {     d7 = d7 + 8; } 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -