2

As we know latest API level in android version don't allow long background task in application. So, how can I run my 12 Hours countdown Timer in background because I have to do some task on Timer finish. So How can I achieve this.

Bhavinkumar Patel
  • 515
  • 1
  • 12
  • 28

2 Answers2

4

The right way to schedule tasks based on time or certain constraints (e.g when device is idle, or when it is charging etc) is by using WorkManager. Take a look at it: https://developer.android.com/topic/libraries/architecture/workmanager/

Specifically, for recurring tasks, have a look at this section: https://developer.android.com/topic/libraries/architecture/workmanager/basics#recurring

Praveen Singh
  • 2,499
  • 3
  • 19
  • 29
0

You need to create a Service and a BroadcastReceiver

here the link to do this :

https://deepshikhapuri.wordpress.com/2016/11/07/android-countdown-timer-run-in-background/

Vaibhav singh
  • 71
  • 2
  • 10