time - Android Chronotmeter onChronometerTick stackoverflowerror? -
i writting code in android develop chronometer app. facing of error while trying reset chronometer on time.
mycode:
mchronometer.setbase(systemclock.elapsedrealtime() - 86396000); mchronometer.start(); mchronometer.setonchronometerticklistener(new chronometer.onchronometerticklistener() { @override public void onchronometertick(chronometer chronometer) { long myelapsedmillis = systemclock.elapsedrealtime() - chronometer.getbase(); if(myelapsedmillis>=86400000) { chronometer.stop(); chronometer.setbase(0); chronometer.start(); } } } );
error:
08-18 02:30:16.793: e/androidruntime(23075): fatal exception: main 08-18 02:30:16.793: e/androidruntime(23075): java.lang.stackoverflowerror 08-18 02:30:16.793: e/androidruntime(23075): @ android.graphics.paint.gettextrunadvances(paint.java:1845) 08-18 02:30:16.793: e/androidruntime(23075): @ android.graphics.paint.gettextrunadvances(paint.java:1818) 08-18 02:30:16.793: e/androidruntime(23075): @ android.text.textline.handletext(textline.java:755) 08-18 02:30:16.793: e/androidruntime(23075): @ android.text.textline.handlerun(textline.java:907) 08-18 02:30:16.793: e/androidruntime(23075): @ android.text.textline.measurerun(textline.java:414) 08-18 02:30:16.793: e/androidruntime(23075): @ android.text.textline.measure(textline.java:293) 08-18 02:30:16.793: e/androidruntime(23075): @ android.text.textline.metrics(textline.java:267) 08-18 02:30:16.793: e/androidruntime(23075): @ android.text.boringlayout.isboring(boringlayout.java:308) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.textview.makesinglelayout(textview.java:6025) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.textview.makenewlayout(textview.java:5917) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.textview.checkforrelayout(textview.java:6501) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.textview.settext(textview.java:3729) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.textview.settext(textview.java:3587) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.textview.settext(textview.java:3562) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.updatetext(chronometer.java:250) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.updaterunning(chronometer.java:257) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.start(chronometer.java:188) 08-18 02:30:16.793: e/androidruntime(23075): @ com.example.androidchronometer.mainactivity$1.onchronometertick(mainactivity.java:46) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.dispatchchronometertick(chronometer.java:279) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.updaterunning(chronometer.java:258) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.start(chronometer.java:188) 08-18 02:30:16.793: e/androidruntime(23075): @ com.example.androidchronometer.mainactivity$1.onchronometertick(mainactivity.java:46) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.dispatchchronometertick(chronometer.java:279) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.updaterunning(chronometer.java:258) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.start(chronometer.java:188) 08-18 02:30:16.793: e/androidruntime(23075): @ com.example.androidchronometer.mainactivity$1.onchronometertick(mainactivity.java:46) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.dispatchchronometertick(chronometer.java:279) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.updaterunning(chronometer.java:258) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.start(chronometer.java:188) 08-18 02:30:16.793: e/androidruntime(23075): @ com.example.androidchronometer.mainactivity$1.onchronometertick(mainactivity.java:46) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.dispatchchronometertick(chronometer.java:279) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.updaterunning(chronometer.java:258) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.start(chronometer.java:188) 08-18 02:30:16.793: e/androidruntime(23075): @ com.example.androidchronometer.mainactivity$1.onchronometertick(mainactivity.java:46) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.dispatchchronometertick(chronometer.java:279) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.updaterunning(chronometer.java:258) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.start(chronometer.java:188) 08-18 02:30:16.793: e/androidruntime(23075): @ com.example.androidchronometer.mainactivity$1.onchronometertick(mainactivity.java:46) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.dispatchchronometertick(chronometer.java:279) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.updaterunning(chronometer.java:258) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.start(chronometer.java:188) 08-18 02:30:16.793: e/androidruntime(23075): @ com.example.androidchronometer.mainactivity$1.onchronometertick(mainactivity.java:46) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.dispatchchronometertick(chronometer.java:279) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.updaterunning(chronometer.java:258) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.start(chronometer.java:188) 08-18 02:30:16.793: e/androidruntime(23075): @ com.example.androidchronometer.mainactivity$1.onchronometertick(mainactivity.java:46) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.dispatchchronometertick(chronometer.java:279) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.updaterunning(chronometer.java:258) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.start(chronometer.java:188) 08-18 02:30:16.793: e/androidruntime(23075): @ com.example.androidchronometer.mainactivity$1.onchronometertick(mainactivity.java:46) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.dispatchchronometertick(chronometer.java:279) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.updaterunning(chronometer.java:258) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.start(chronometer.java:188) 08-18 02:30:16.793: e/androidruntime(23075): @ com.example.androidchronometer.mainactivity$1.onchronometertick(mainactivity.java:46) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.dispatchchronometertick(chronometer.java:279) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.updaterunning(chronometer.java:258) 08-18 02:30:16.793: e/androidruntime(23075): @ android.widget.chronometer.start(chronometer.java:188) 08-18 02:30:16.793: e/androidruntime(23075): @ com.example.androidchronometer.mainactivity$1.onchronometertick
i facing stackoverflowerror , while trying reset chronometer on time.
please let me know , how can rid of error , please suggest me possible solution problem.
set base systemclock.elapsedrealtime()
instead of 0
:
public void onchronometertick(chronometer chronometer) { // ... chronometer.setbase(systemclock.elapsedrealtime()); chronometer.start(); // ... }
Comments
Post a Comment