0

I am showing a popup screen when the screen is locked when some event happens.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
            WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
            WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}

Problem is - after a lot of frustration I found this answer, saying that this doesn't work when the activity is using a Theme.Dialog.

I want my activity to not be full screen, its suppose to be more or less like a sms popup notification. how can I do that without the Theme.Dialog Theme?

Community
  • 1
  • 1
Ofek Agmon
  • 5,040
  • 14
  • 57
  • 101

1 Answers1

0

Not sure if this is what you're looking for, but this wraped everything in the window that pops up for me:

Key part of code is 'WRAP_CONTENT':

    WindowManager mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    View mView = View.inflate(getApplicationContext(), R.layout.dialogue_page, null);
    WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0,
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                    | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                    | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
                    | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
            PixelFormat.RGBA_8888);
    mWindowManager.addView(mView, mLayoutParams);
XMAN
  • 176
  • 1
  • 3
  • 12