I want to show notification when my application is on spacified activity and in background mode.
So i add notification in onPause and clear notification in onResume.
But the problem is when I switch actuvities the notification comes up.
Any advice how to fix it?
Switching activities causes onPause() to fire. Technically, switching Activities fulfills your notion of “background mode”. Bear in mind that Activities don’t really do anything in the background, and that once they’re backgrounded they can be destroyed at any moment should the Dalvik VM decide it needs that memory. In other words, there’s probably a better way to accomplish what you’re after.