How to call rest api in background even when the app is closed in ionic for android platform?

We used the plugins from ionicframework documentation mentioned in the developers section for background mode services. but after subscribing the background task in ionic the code or task is executed when the app is active or open . The service stops when the app is closed . Need sample code help or sample source code for the same. Thanks in advance.