0

i have a problem regrading the android app development.

i'm developing an android app and it have a timer function,it's like simple clock .It get and show total time for each task completed.

When start task and Chronometer.start() timer then finished and Chronometer.stop() and get total time to each task. in my activity show this Chronometer timer value.

this all function working fine,but i need run this on as a background service.

it's mean app kill app,when after open need to get correct time..

in my application kill and re open application Chronometer start in 0 time.

if have any suggestion for these scenario please share it with my.. this Chronometer have UI element because can not add this in the service..

in my case suitable trimmer widgets is the this Chronometer widgets.

thank you,,

CHAMI
  • 31
  • 1
  • 8
  • Why don't you try with a timer. Check this https://stackoverflow.com/questions/38826184/chronometer-keep-in-background-time-spent – Jaymin Apr 02 '20 at 05:36
  • Why don't you store the start time in a file, i.e. shared preference, and estimate the elapsed time by taking the difference between System.currentTimeMiliss() and that stored value? [1] https://developer.android.com/reference/android/content/SharedPreferences – Ian Medeiros Apr 02 '20 at 05:47
  • @lan why use shared preference and which value store it? – CHAMI Apr 02 '20 at 07:26
  • @Jaymin thanks for your suggestion but how i pass real timer data to the activity – CHAMI Apr 02 '20 at 07:27
  • The static variable will solve the issue. – Jaymin Apr 02 '20 at 07:29

0 Answers0