'Workmanager stops working, and instantly access dowork method when main activity is open

My Workmanager needs to send notification every hour, and it is working fine on Nokia and Motorola. However, it is killed by the system on Honor. That's okay, I accepted it, but the problem is that as soon as user opens Main activity, Workmanager instantly access dowork() method and sends notification. Is it possible to delay dowork a bit, or to forbid notification sending if main activity is visible/in foreground and less than minute have passed since main activity was open?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source