Search code examples
androidbackgroundforeground

What exactly is the foreground in Android?


I came across questions addressed android concepts around foreground - https://stackoverflow.com/questions/20647168/android-how-to-find-if-any-app-is-running-in-foreground. I need some clarification on the term foreground used in android. I think I have a working definition of background in android - something that happens you cannot see on the screen. Would foreground just be stuff that you can see and interact with on the screen. Like if I were to play a game of flappy bird, would the game itself(bird jumping over pipes) be the foreground because I can see it and interact it with. Based off that would the game music be in the background because I cannot see it?


Solution

  • Would foreground just be stuff that you can see and interact with on the screen.

    IMHO yes, basically foreground is a state in which user can interact with the application through android component like Activity or service. Take example of Musicplayer playing music in foreground service. Also if you have to interact with application through Actvity, the activity has to be in forground. User can't interact with app even if the activity is visible but not in foreground.