Detect if an android app is running on background
<p>I want to check if my app is running on a background mode.</p>

<p>The problem is that i have many activities(list activities, map activities etc.). Initially I have tried in the life cycle's resume and pause(or the <code>onUserLeaveHint</code>) methods to set a static boolean as true or false and work with this way. But this obviously can't work because when I move from one activity to another, the previous one get paused. </p>

<p>Also, I've read here on stackoverflow that the <code>getRunningTasks()</code> should be used only for debugging purposes. I did a huge research but I can't find a solution. All I want to do is to be able to detect if a the app is running on a background. Can anyone propose me a way, or express any thought on how can I do that?</p>
