How To Run Timer On App Background

Any One help me how to run timer on app background

Yeah, I can.

Firstly, when app closes, call tiny db save time and when the app will reinitialize, call tinydb get value and subtract it from time during which app was closed