I want to display an Activity in front of the Lockscreen. I tried with this code in my onCreate medthod:
super.onCreate(savedInstanceState);
Window window = getWindow();
window.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
setContentView(R.layout.test);
That works great for Activities which are displayed over the whole screen but I want to build an Activity which is only 200px heigh. I thought I can match it with this code:
super.onCreate(savedInstanceState);
Window window = getWindow();
LayoutParams layout = new WindowManager.LayoutParams();
layout.copyFrom(window.getAttributes());
layout.height = 200;
window.setAttributes(layout);
window.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
setContentView(R.layout.test);
But then the Activity is not visible in front of the lockscreen. If I unlock the phone the Activity is displayed directly. Any ideas why and how I can fix this?
EDIT: I think it has something to do with the window floating FLAG. If this flag is set (and I think it will when I change the size) the activity is not displayed over the lockscreen. But this is only a presumption. Any ideas or a workaround to fix this?