0

I have background long running task service, From developer site i found some word like "If your app targets API level 26 or higher, the system imposes restrictions on running background services when the app itself is not in the foreground. In most cases like this, your app should use a scheduled job instead. " https://developer.android.com/topic/performance/scheduling.html How to replace service to scheduling task? is this will work continuously in background ?

Tim
  • 41,901
  • 18
  • 127
  • 145
Jaydeep purohit
  • 1,536
  • 17
  • 20
  • 1
    *this will work continuously in background ?* - no. simply put, they don't want you to have long running background services – Tim Nov 21 '17 at 13:21
  • please refer this link https://stackoverflow.com/questions/47090007/service-automatically-stops-after-several-minutes – Vikas singh Nov 21 '17 at 13:22
  • "I have background long running task service" -- why? What specifically is it doing? The only way to have a long-running service is to have it be a foreground service (e.g., `startForeground()`). – CommonsWare Nov 21 '17 at 13:34

1 Answers1

1

The preferred way is to use Android Job Scheduler or Firebase Job Dispatcher. However you can not run task for a long time but what you can do is run your task after specific time intervals for a short period of time.

  • When i got push notification from server i have to start one service for calling api to fetch near by venues and register geofence in background. – Jaydeep purohit Nov 22 '17 at 05:21
  • You can notify the Job Scheduler to perform a specific task when a notification is received. –  Nov 22 '17 at 07:06