I want to detect current foreground activity from a background service.
Particularly I want to know if Home activity is currently on the top of android activity stack or not.
Use case is something like: If home activity is on foreground (i.e User is not using any other application) I need to show a alert dialog on some event in background service. But if, Home activity is not on top of stack (i.e. user is using some other application), i am supposed to show a notification in status bar on some event in service.
Is there any way to detect current foreground activity?
See this here
Here you can find the foreground Activity then compare its package with the home package.Its may be android.home