0

I am working on an application that uses JobService. Now, in my app i want to reschedule the Broadcast receiver that is working in the background. So, i want to know if i can implement BroadcastReceiver inside JobService so that it can restart after several times.

Nayantara Jeyaraj
  • 2,624
  • 7
  • 34
  • 63
Piyush k
  • 297
  • 3
  • 14

1 Answers1

0

Yes it is possible. If it's background service, use PowerManager and WakeLock to keep CPU running while you you restart your service. Btw why you need to restart it?

EDIT:

if you want to keep alive your service return START_STICKY in your onStartCommand()

Vygintas B
  • 1,624
  • 13
  • 31
  • Because. some times system kills background service.....when memory is low....i want to rescedule it after sometime so, even if service is killed by system It autometically restart it... – Piyush k Jul 22 '16 at 05:29
  • If you want to keep service running and restart it if it's killed `return START_STICKY` in your service's `onStartCommand()` method. – Vygintas B Jul 22 '16 at 05:43
  • I have already done that and also implement 'BOOT_COMPLETED' but, somehow system kills services. when memory is low – Piyush k Jul 22 '16 at 05:46
  • Yes it does kill it, but it will restart it then memory is available. – Vygintas B Jul 22 '16 at 05:47
  • Is your service defined in Manifest? – Vygintas B Jul 22 '16 at 05:52