java - Android Timer SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length -
after looking fo ther error @ least @ fourm , found answers speak 3rd party device keyborad or somthing caused it(samsung devices @ least)(iam using 1 plus one). ive setted timer 10 seconds , every time reached 3rd time of runnig (i refresh activity) got error span_exclusive_exclusive spans cannot have 0 length.
timerattack class code:
@suppresslint("newapi") public class timeattack extends activity implements animationlistener { string pic;//תמונה של הדגל button answer1;//תשובות button answer2; button answer3; button answer4; button hint; textview guess; textview numofguess; textview score; textview scorenum; textview textviewtime; mediaplayer mphint; mediaplayer mpnext; mediaplayer mpwrong; animation animationfadein; animation animationfadeout; string fn; guesses g; score s; timer t; button [] b = new button[4]; databasehandler db = new databasehandler(this); list<string>wronganswers=new arraylist<string>(); int countg=0;//count guesses int counta=0;//count right answers int countq=0;//count questions @suppresslint("newapi") @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_third); actionbar actionbar = getactionbar(); actionbar.setdisplayhomeasupenabled(true); score =(textview)findviewbyid(r.id.score); scorenum =(textview)findviewbyid(r.id.scorenum); scorenum.settext(string.valueof(s.score)); guess =(textview)findviewbyid(r.id.guesses); numofguess=(textview)findviewbyid(r.id.numofguesses); numofguess.settext(string.valueof(guesses.numofguesses)); textviewtime = (textview) findviewbyid(r.id.textviewtime); hint =(button)findviewbyid(r.id.hint); hint.setonclicklistener(hintonclicklistener); mphint = mediaplayer.create(this,r.raw.hint_sound); mpnext = mediaplayer.create(this, r.raw.next_flag); mpwrong = mediaplayer.create(this, r.raw.wrong_answer); animationfadein = animationutils.loadanimation(this, r.anim.fade_in); animationfadeout = animationutils.loadanimation(this, r.anim.fade_out); textviewtime.settext(t.time); final counterclass timer = new counterclass(11000, 1000); timer.start(); flags f = new flags(); random r = new random();//הדגל שיבחר לשאלה int num = r.nextint(160);//up f = db.getflag(num);//הצגת הדגל הרנדומלי שיצא fn = f.getname().tostring(); pic = f.getimage().tostring(); pic_view(pic);//מעבר לפונקציה להשמת התמונה של הדגל במשחק //מערך ארבע כפתורים כנגד ארבע תשובות b[0] = (button)findviewbyid(r.id.button1); b[1] = (button)findviewbyid(r.id.button2); b[2] = (button)findviewbyid(r.id.button3); b[3] = (button)findviewbyid(r.id.button4); list<string>answers=new arraylist<string>();//מערך תשובות answers.add(f.getname().tostring());//הוספת התשובה הנכונה for(int i=1;i<4;i++) { num = r.nextint(200); string valtoadd1 = db.getflag(num).getname().tostring(); if(!answers.contains(valtoadd1)){ wronganswers.add(valtoadd1); answers.add(valtoadd1); } } collections.shuffle(answers);//ערבוב התשובות for(int i=0;i<answers.size();i++) { b[i].settext(answers.get(i));//השמת התשובות מהמהערך למערך הכפתורים b[i].startanimation(animationfadein); } }//end of oncreat public boolean onoptionsitemselected(menuitem item){//actionbar activity intent myintent = new intent(getapplicationcontext(), mainactivity.class); startactivityforresult(myintent, 0); return true; } @suppresslint("newapi") public void resetquiz() { countq++; recreate(); } private onclicklistener hintonclicklistener = new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub mphint.start(); /*if(guesses.numofguesses==1) { g.setnumofguesses(3); finish();//כאשר מספר הניחושים return; } else*/ g.numofguesses++; numofguess.settext(string.valueof(guesses.numofguesses)); int invisblecount=0; for(int i=0;i<b.length;i++){ if(invisblecount<2){ string buttontext = b[i].gettext().tostring(); if(buttontext.equals(wronganswers.get(0))||buttontext.equals(wronganswers.get(1))) { b[i].startanimation(animationfadeout); b[i].setvisibility(view.invisible); invisblecount++; } } } } }; public void check(view v) { log.d("yes", fn); button b = (button)v; string text = b.gettext().tostring(); if(text.equals(fn)) { mpnext.start(); s.score+=5; resetquiz(); } else { mpwrong.start(); guesses.numofguesses++; countg=guesses.numofguesses; /*if(guesses.numofguesses==1) { //g.setnumofguesses(3); //finish();//כאשר מספר הניחושים return; }else guesses.numofguesses--;*/ if(s.score>0) s.score-=5; scorenum.settext(string.valueof(s.score)); numofguess.settext(string.valueof(guesses.numofguesses)); } } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.second, menu); return true; } private void pic_view(string pic2) { // todo auto-generated method stub //גישה לדגל לפי שמו וייבוא התמונה log.d("result pic function " , pic2); imageview imageview = (imageview)findviewbyid(r.id.imageview1); string uri ="@drawable/"; uri += pic2; int imageresource = getresources().getidentifier(uri, pic2, getpackagename());//הצוות התמונה drawable res= getresources().getdrawable(imageresource);//ציור התמונה imageview.setimagedrawable(res); } @override public void onanimationend(animation animation) { // todo auto-generated method stub toast.maketext(getbasecontext(), "animatoin stoped", toast.length_short).show(); } @override public void onanimationrepeat(animation animation) { // todo auto-generated method stub } public void onanimationstart(animation animation) { // todo auto-generated method stub } public class counterclass extends countdowntimer { public counterclass(long millisinfuture, long countdowninterval) { super(millisinfuture, countdowninterval); // todo auto-generated constructor stub } @suppresslint("newapi") @targetapi(build.version_codes.gingerbread) @override public void ontick(long millisuntilfinished) { // todo auto-generated method stub long millis = millisuntilfinished; string hms = string.format("%02d:%02d:%02d", timeunit.milliseconds.tohours(millis), timeunit.milliseconds.tominutes(millis) - timeunit.hours.tominutes(timeunit.milliseconds.tohours(millis)), timeunit.milliseconds.toseconds(millis) - timeunit.minutes.toseconds(timeunit.milliseconds.tominutes(millis))); system.out.println(hms); textviewtime.settext(hms); } @override public void onfinish() { // todo auto-generated method stub log.d("time", "more" + textviewtime.gettext().tostring()); toast toast = toast.maketext(getapplicationcontext(), "time's lets see made far...", toast.length_short); toast.show(); intent en = new intent(timeattack.this,person.class); string = scorenum.gettext().tostring(); en.putextra("score",extra); startactivity(en); } } }
stacktrace:
04-26 11:26:15.590: i/system.out(5670): 00:00:08 04-26 11:26:15.610: i/system.out(5670): 00:00:03 04-26 11:26:16.590: i/system.out(5670): 00:00:07 04-26 11:26:16.620: i/system.out(5670): 00:00:02 04-26 11:26:17.590: i/system.out(5670): 00:00:06 04-26 11:26:17.630: i/system.out(5670): 00:00:01 04-26 11:26:18.590: i/system.out(5670): 00:00:05 04-26 11:26:19.130: d/yes(5670): finland 04-26 11:26:19.320: d/into(5670): com.example.flagsgame.flags@42cc7998 04-26 11:26:19.320: d/into(5670): 147 04-26 11:26:19.320: d/result pic function(5670): palau 04-26 11:26:19.420: d/into(5670): com.example.flagsgame.flags@428a6720 04-26 11:26:19.420: d/into(5670): 119 04-26 11:26:19.460: d/into(5670): com.example.flagsgame.flags@42d8f3d0 04-26 11:26:19.460: d/into(5670): 37 04-26 11:26:19.490: d/into(5670): com.example.flagsgame.flags@42b7ff38 04-26 11:26:19.490: d/into(5670): 183 04-26 11:26:19.510: e/mediaplayer(5670): should have subtitle controller set 04-26 11:26:19.510: e/mediaplayer(5670): should have subtitle controller set 04-26 11:26:19.510: e/mediaplayer(5670): should have subtitle controller set 04-26 11:26:19.510: i/system.out(5670): 00:00:10 04-26 11:26:19.510: d/time(5670): more00:00:01 04-26 11:26:19.530: i/timeline(5670): timeline: activity_launch_request id:com.example.flagsgame time:36376629 04-26 11:26:19.710: w/mediaplayer-jni(5670): mediaplayer finalized without being released 04-26 11:26:19.710: w/mediaplayer-jni(5670): mediaplayer finalized without being released 04-26 11:26:19.720: w/mediaplayer-jni(5670): mediaplayer finalized without being released 04-26 11:26:19.720: w/bundle(5670): key score expected integer value java.lang.string. default value 0 returned. 04-26 11:26:19.730: w/bundle(5670): attempt cast generated internal exception: 04-26 11:26:19.730: w/bundle(5670): java.lang.classcastexception: java.lang.string cannot cast java.lang.integer 04-26 11:26:19.730: w/bundle(5670): @ android.os.bundle.getint(bundle.java:1000) 04-26 11:26:19.730: w/bundle(5670): @ android.content.intent.getintextra(intent.java:4620) 04-26 11:26:19.730: w/bundle(5670): @ com.example.flagsgame.person.oncreate(person.java:40) 04-26 11:26:19.730: w/bundle(5670): @ android.app.activity.performcreate(activity.java:5231) 04-26 11:26:19.730: w/bundle(5670): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087) 04-26 11:26:19.730: w/bundle(5670): @ android.app.activitythread.performlaunchactivity(activitythread.java:2169) 04-26 11:26:19.730: w/bundle(5670): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2271) 04-26 11:26:19.730: w/bundle(5670): @ android.app.activitythread.access$800(activitythread.java:144) 04-26 11:26:19.730: w/bundle(5670): @ android.app.activitythread$h.handlemessage(activitythread.java:1205) 04-26 11:26:19.730: w/bundle(5670): @ android.os.handler.dispatchmessage(handler.java:102) 04-26 11:26:19.730: w/bundle(5670): @ android.os.looper.loop(looper.java:136) 04-26 11:26:19.730: w/bundle(5670): @ android.app.activitythread.main(activitythread.java:5146) 04-26 11:26:19.730: w/bundle(5670): @ java.lang.reflect.method.invokenative(native method) 04-26 11:26:19.730: w/bundle(5670): @ java.lang.reflect.method.invoke(method.java:515) 04-26 11:26:19.730: w/bundle(5670): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:796) 04-26 11:26:19.730: w/bundle(5670): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:612) 04-26 11:26:19.730: w/bundle(5670): @ dalvik.system.nativestart.main(native method) 04-26 11:26:19.800: i/system.out(5670): 00:00:04 04-26 11:26:19.910: i/timeline(5670): timeline: activity_idle id: android.os.binderproxy@42b40b18 time:36377008 04-26 11:26:19.920: e/spannablestringbuilder(5670): span_exclusive_exclusive spans cannot have 0 length 04-26 11:26:19.920: e/spannablestringbuilder(5670): span_exclusive_exclusive spans cannot have 0 length 04-26 11:26:19.930: e/spannablestringbuilder(5670): span_exclusive_exclusive spans cannot have 0 length 04-26 11:26:19.930: e/spannablestringbuilder(5670): span_exclusive_exclusive spans cannot have 0 length 04-26 11:26:20.510: i/system.out(5670): 00:00:09 04-26 11:26:20.800: i/system.out(5670): 00:00:03 04-26 11:26:21.510: i/system.out(5670): 00:00:08 04-26 11:26:21.800: i/system.out(5670): 00:00:02 04-26 11:26:22.510: i/system.out(5670): 00:00:07 04-26 11:26:22.800: i/system.out(5670): 00:00:01 04-26 11:26:23.510: i/system.out(5670): 00:00:06 04-26 11:26:24.050: d/time(5670): more00:00:01 04-26 11:26:24.060: i/timeline(5670): timeline: activity_launch_request id:com.example.flagsgame time:36381154 04-26 11:26:24.150: w/bundle(5670): key score expected integer value java.lang.string. default value 0 returned. 04-26 11:26:24.150: w/bundle(5670): attempt cast generated internal exception: 04-26 11:26:24.150: w/bundle(5670): java.lang.classcastexception: java.lang.string cannot cast java.lang.integer 04-26 11:26:24.150: w/bundle(5670): @ android.os.bundle.getint(bundle.java:1000) 04-26 11:26:24.150: w/bundle(5670): @ android.content.intent.getintextra(intent.java:4620) 04-26 11:26:24.150: w/bundle(5670): @ com.example.flagsgame.person.oncreate(person.java:40) 04-26 11:26:24.150: w/bundle(5670): @ android.app.activity.performcreate(activity.java:5231) 04-26 11:26:24.150: w/bundle(5670): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087) 04-26 11:26:24.150: w/bundle(5670): @ android.app.activitythread.performlaunchactivity(activitythread.java:2169) 04-26 11:26:24.150: w/bundle(5670): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2271) 04-26 11:26:24.150: w/bundle(5670): @ android.app.activitythread.access$800(activitythread.java:144) 04-26 11:26:24.150: w/bundle(5670): @ android.app.activitythread$h.handlemessage(activitythread.java:1205) 04-26 11:26:24.150: w/bundle(5670): @ android.os.handler.dispatchmessage(handler.java:102) 04-26 11:26:24.150: w/bundle(5670): @ android.os.looper.loop(looper.java:136) 04-26 11:26:24.150: w/bundle(5670): @ android.app.activitythread.main(activitythread.java:5146) 04-26 11:26:24.150: w/bundle(5670): @ java.lang.reflect.method.invokenative(native method) 04-26 11:26:24.150: w/bundle(5670): @ java.lang.reflect.method.invoke(method.java:515) 04-26 11:26:24.150: w/bundle(5670): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:796) 04-26 11:26:24.150: w/bundle(5670): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:612) 04-26 11:26:24.150: w/bundle(5670): @ dalvik.system.nativestart.main(native method) 04-26 11:26:24.270: e/spannablestringbuilder(5670): span_exclusive_exclusive spans cannot have 0 length 04-26 11:26:24.270: e/spannablestringbuilder(5670): span_exclusive_exclusive spans cannot have 0 length 04-26 11:26:24.270: i/timeline(5670): timeline: activity_idle id: android.os.binderproxy@426f66b0 time:36381361 04-26 11:26:24.520: i/system.out(5670): 00:00:05 04-26 11:26:25.520: i/system.out(5670): 00:00:04 04-26 11:26:26.520: i/system.out(5670): 00:00:03 04-26 11:26:27.520: i/system.out(5670): 00:00:02 04-26 11:26:28.520: i/system.out(5670): 00:00:01 04-26 11:26:30.240: d/time(5670): more00:00:01 04-26 11:26:30.250: i/timeline(5670): timeline: activity_launch_request id:com.example.flagsgame time:36387346 04-26 11:26:30.320: w/bundle(5670): key score expected integer value java.lang.string. default value 0 returned. 04-26 11:26:30.320: w/bundle(5670): attempt cast generated internal exception: 04-26 11:26:30.320: w/bundle(5670): java.lang.classcastexception: java.lang.string cannot cast java.lang.integer 04-26 11:26:30.320: w/bundle(5670): @ android.os.bundle.getint(bundle.java:1000) 04-26 11:26:30.320: w/bundle(5670): @ android.content.intent.getintextra(intent.java:4620) 04-26 11:26:30.320: w/bundle(5670): @ com.example.flagsgame.person.oncreate(person.java:40) 04-26 11:26:30.320: w/bundle(5670): @ android.app.activity.performcreate(activity.java:5231) 04-26 11:26:30.320: w/bundle(5670): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087) 04-26 11:26:30.320: w/bundle(5670): @ android.app.activitythread.performlaunchactivity(activitythread.java:2169) 04-26 11:26:30.320: w/bundle(5670): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2271) 04-26 11:26:30.320: w/bundle(5670): @ android.app.activitythread.access$800(activitythread.java:144) 04-26 11:26:30.320: w/bundle(5670): @ android.app.activitythread$h.handlemessage(activitythread.java:1205) 04-26 11:26:30.320: w/bundle(5670): @ android.os.handler.dispatchmessage(handler.java:102) 04-26 11:26:30.320: w/bundle(5670): @ android.os.looper.loop(looper.java:136) 04-26 11:26:30.320: w/bundle(5670): @ android.app.activitythread.main(activitythread.java:5146) 04-26 11:26:30.320: w/bundle(5670): @ java.lang.reflect.method.invokenative(native method) 04-26 11:26:30.320: w/bundle(5670): @ java.lang.reflect.method.invoke(method.java:515) 04-26 11:26:30.320: w/bundle(5670): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:796) 04-26 11:26:30.320: w/bundle(5670): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:612) 04-26 11:26:30.320: w/bundle(5670): @ dalvik.system.nativestart.main(native method) 04-26 11:26:30.370: i/timeline(5670): timeline: activity_idle id: android.os.binderproxy@42b6b638 time:36387461 04-26 11:26:30.370: e/spannablestringbuilder(5670): span_exclusive_exclusive spans cannot have 0 length 04-26 11:26:30.370: e/spannablestringbuilder(5670): span_exclusive_exclusive spans cannot have 0 length 04-26 11:27:03.740: w/iinputconnectionwrapper(5670): getextractedtext on inactive inputconnection 04-26 11:27:03.740: w/iinputconnectionwrapper(5670): gettextbeforecursor on inactive inputconnection 04-26 11:27:03.740: w/iinputconnectionwrapper(5670): getselectedtext on inactive inputconnection 04-26 11:27:03.740: w/iinputconnectionwrapper(5670): gettextaftercursor on inactive inputconnection
as can see timer still runnig after error got. error: span_exclusive_exclusive spans cannot have 0 length
Comments
Post a Comment