java - How to know if an app is in foreground or not? -


check if app in foreground or not.

note: app targeting lollipop , above versions in android

yeah way can through accessibility service. @ page understand how create it. https://developer.android.com/training/accessibility/service.html need enable service via services -> accessibility screen.

accessibilityevent.type_window_state_changed can interrogate package in front figure out if instigram on top.

you don't want use getrunningtasks since function modified in android 5.0+


Comments