question

khurram avatar image
khurram asked David Marginian Deactivated edited

Our foreground service is getting killed by operating system

Hi team,

we have a native application installed in our clover station which keep listening for our new online orders and when a new order comes it send a print job to print order.

We are using a foreground service to perform this listening process for new orders.

Now the problem is that after one or two days our foreground service get killed and after that our app won’t print any order and even we are not getting notified if our service is killed.

Please suggest us any solution to avoid our service being get killed?
or if we can avoid using foreground service and rely on some listeners of clover instead of this?

REST APIClover Station
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated edited

This is not a Clover specific problem, it is an Android problem, please see Jeffrey's response here: https://community.clover.com/questions/24078/how-to-set-listener-in-my-android-app-when-create.html.

There isn't a way to indefinitely listen for order updates because Android may remove your process because of memory / resource pressure from other apps. The best you can do is register your listener in a foreground service but even that is not guaranteed to keep it running.

The correct thing is to use Work Manager to periodically wake up and perform some work. This may not support your use case well however since Work Manager jobs aren't guaranteed to run at any particular time, and if you try to wake up frequently the OS is going to throttle your jobs.


2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

khurram avatar image khurram commented ·

Actually clover rest api should have this printing feature for orders. This additional native app requirement is a lot of problem and we are really suffering with it.

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ khurram commented ·

I understand the frustration, we do have some open issues for supporting this but it hasn't been a priority. There is a 3rd party app that I can't recommend (because I haven't tried using it) but you may want to investigate called Smart Print - https://www.clover.com/appmarket/apps/25BCJ2KGEJNEC.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community