Don't have Telegram yet? Try it now!
https://techpaliyal.com/android-how-to-check-app-is-in-foreground-or-background/
Android How to check app is in Foreground or background