Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a fullscreen TYPE_SYSTEM_ALERT window?

I'm currently having a hard time displaying a TYPE_SYSTEM_ALERT window in fullscreen mode. I'd like to do so in order to have an overlay view, created from a service, on top of the status bar but without hiding it.

However, putting the FLAG_FULLSCREEN flag in the layout params of the window I'm creating doesn't seem to work. I found the STATUS_BAR and EXPAND_STATUS_BAR permissions but I couldn't find how to make use of them.

Here are the LayoutParams :

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            PixelFormat.TRANSLUCENT);

    params.gravity = Gravity.RIGHT | Gravity.TOP;

    mWindowManager.addView(mOverlayView, params);

Any ideas?

Thank you

like image 897
Toop Avatar asked Jun 16 '11 11:06

Toop


2 Answers

I found the solution while trying to do something else!

In order to have a TYPE_SYSTEM_ALERT window on top of every other window AND on top of the status bar you must add the FLAG_LAYOUT_IN_SCREEN flag and not the FLAG_LAYOUT_FULLSCREEN flag :

WindowManager.LayoutParams params = new WindowManager.LayoutParams(
        WindowManager.LayoutParams.WRAP_CONTENT,
        WindowManager.LayoutParams.WRAP_CONTENT,
        WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
        WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
        PixelFormat.TRANSLUCENT);

mWindowManager.addView(mOverlayView, params);
like image 55
Toop Avatar answered Nov 27 '22 14:11

Toop


It doesn't work anymore in Ice Cream Sandwich. The Status bar covers a TYPE_SYSTEM_ALERT window. But TYPE_SYSTEM_OVERLAY still works fine.

like image 40
deviant Avatar answered Nov 27 '22 14:11

deviant