show notification from google chat activity only when activity is in background
<p>This is a Google Chat application. When I get a message from Google Chat I want to show it in the status bar as a notification when the activity is in background.</p>

<p>I tried setting boolean values in the <code>onPause()</code> method but it did not work.</p>

<pre><code>public void addMessage(String chatid, String msg) {
    // I want to the execute this line only when the activity is in background
    notify.getCurrentActivity(getApplicationContext(), msg, fromName, chatid);
}

public void getCurrentActivity(Context context, String msg){
    showNotification(context, msg, fromName, fromChatID);
}
</code></pre>
