First off, you will be told that this is a bad thing to do, that it is against the Android way of doing things. Users do not like this. And that the Notification area is much better way to do this.
That said... there are ways to accomplish this...
A Toast
will display no matter which activity is on the screen. So you could set up a background thread (or better a Service
) that will display your information in a Toast
. This might be good enough for you.
You may find it useful looking at some Toast
source code here.
Also here is a nice page on how to create a custom Toast
layout by replacing the default View
with one of your own. (I have not done this, but it looks quite interesting):
The alternative is much more difficult, and is to display a System Overlay window. Unfortunately you have to do quite a lot of work to get these set up properly.
Here are a few related questions that I used to get it working:
Each of these has links to many others - there are loads of System Overlay questions on here.
But things to remember:
- In the old days, you could put a system overlay on top, and send
touches through to the activity below. This is no longer possible,
and so a lot of the answers are now out of date.
- You may need to
play around with the flags in the provided examples to get exactly
the effect you are aiming for. Not all the examples use the same
flags, so there are some subtle differences in how each solution
works.
Then again, I also believe that the Notification area is a much better UI pattern to use, so I do recommend you try that first. It is easier to do, and most of us expect that type of behaviour rather than a pop-up.
The problem with a pop-up, is that it might interrupt a movie I'm watching. Or a game I'm playing.