android java count down timer with background service

Viewed 139

I want to make a task which,

functions as a count-down timer

*which work on activity (show the count-down in the text field )

*and background at the same time.

*Then background service shows a notification after the count-down finished,

*not just that if the app is closed and reopen, I want to show up the remaining time in the text field

what should I do, to achieve these four jobs

1 Answers

Try to open a service on foreground method (background service cannot act well nowadays), it is up to you. Your task counting info will save in (foreground) service So when your app will reopen, your MainActivity will collect data from your service and display it in own TextBox. For collecting data from service you can use BroadcastReceiver which starts within service. You can show a notification from your service, it will be better if time count is end before app reopen. You also can show notification from your activity if you ensure that user have to return your app before count down end.

I have not enough reputation for comment thats why i replied for answer.

Related