I am building an app which has a background service that sends a broadcast message when it meets certain location and time criteria, and a broadcast receiver that opens a new activity when that happens. However, the activity then covers the whole screen, and that's not what I really want to do.
Instead I want the broadcast receiver to trigger some kind of pop-up that only occupies a part of the screen and leaves whatever other apps were running (e.g. phone call, video, web browser etc.) still visible on the rest of the screen.
It doesn't matter what the pop-up is. It could be a snackbar, a dialog box or simply an activity layout that only covers part of the screen. The only criteria are that it must be able to display text and must be able to include OK and CANCEL buttons.
I have tried various suggestions from earlier questions, but can't get anything to work. Can anyone suggest a way of doing this?
I successfully reduced the size of the activity layout to be smaller than the screen using the following code:
WindowManager.LayoutParams params = getWindow().getAttributes();
params.x = -100;
params.height = 200;
params.width = 1000;
params.y = -50;
this.getWindow().setAttributes(params);
but the surrounding screen area is just black. I guess what I have done here is reduced the size of the display for everything to be smaller than the screen, and that's not what I want. I want only to reduce the size of the one activity, with whatever app layout is beneath it showing around it at full screen size.